rails server not working, Rails 4.2.0 - ruby-on-rails-4.2

I'm following the Rails tutorial by Michael Hartl and after i bundle install all the required gems the rails server gives me an error when i run it. Im using Windows
here's the error:
C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/web-console-2.0.0.beta3/lib/web_console/slave.rb:1:in `require': cannot load such file -- pty (LoadError)
C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/web-console-2.0.0.beta3/lib/web_console/slave.rb:1:in `require': cannot load such file -- pty (LoadError)
from C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/web-console-2.0.0.beta3/lib/web_console.rb:13:in `require'
from C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/web-console-2.0.0.beta3/lib/web_console.rb:13:in `<top (required)>'
from C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/web-console-2.0.0.beta3/lib/web-console.rb:1:in `require'
from C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/web-console-2.0.0.beta3/lib/web-console.rb:1:in `<top(required)>'
from C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/bundler-1.7.7/lib/bundler/runtime.rb:76:in `require'
from C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/bundler-1.7.7/lib/bundler/runtime.rb:76:in `block (2 levels) in require'
from C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/bundler-1.7.7/lib/bundler/runtime.rb:72:in `each'
from C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/bundler-1.7.7/lib/bundler/runtime.rb:72:in `block in require'
from C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/bundler-1.7.7/lib/bundler/runtime.rb:61:in `each'
from C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/bundler-1.7.7/lib/bundler/runtime.rb:61:in `require'
from C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/bundler-1.7.7/lib/bundler.rb:133:in `require'
from C:/sites/sample_app/config/application.rb:7:in `<top(required)>'
from C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/railties-4.2.0/lib/rails/commands/commands_tasks.rb:78:in `require'
from C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/railties-4.2.0/lib/rails/commands/commands_tasks.rb:78:in `block in server'
from C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/railties-4.2.0/lib/rails/commands/commands_tasks.rb:75:in `tap'
from C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/railties-4.2.0/lib/rails/commands/commands_tasks.rb:75:in `server'
from C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/railties-4.2.0/lib/rails/commands/commands_tasks.rb:39:in `run_command!'
from C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/railties-4.2.0/lib/rails/commands.rb:17:in `<top (required)>'
from bin/rails:4:in `require'
from bin/rails:4:in `<main>'
here is the Gemfile:
source 'https://rubygems.org'
gem 'rails', '4.2.0'
gem 'bcrypt', '3.1.7'
gem 'faker', '1.4.2'
gem 'carrierwave', '0.10.0'
gem 'mini_magick', '3.8.0'
gem 'fog', '1.23.0'
gem 'will_paginate', '3.0.7'
gem 'bootstrap-will_paginate', '0.0.10'
gem 'bootstrap-sass', '3.2.0.0'
gem 'sass-rails', '5.0.2'
gem 'uglifier', '2.5.3'
gem 'coffee-rails', '4.1.0'
gem 'jquery-rails', '4.0.3'
gem 'turbolinks', '2.3.0'
gem 'jbuilder', '2.2.3'
gem 'sdoc', '0.4.0', group: :doc
group :development, :test do
gem 'sqlite3', '1.3.9'
gem 'byebug', '3.4.0'
gem 'web-console', '2.0.0.beta3'
gem 'spring', '1.1.3'
end
group :test do
gem 'minitest-reporters', '1.0.5'
gem 'mini_backtrace', '0.1.3'
gem 'guard-minitest', '2.3.1'
end
group :production do
gem 'pg', '0.17.1'
gem 'rails_12factor', '0.0.2'
gem 'puma', '2.11.1'
end
all help is greatly appreciated

Looking at the error it seems the web-console gem in your dev group is causing the issue. Some looking around online and it appears that this particular gem does not work well in a Windows environment (Arguably, Rails as a whole does not cooperate on a Windows machine).
Try commenting out web-console and then bundle install, rails c
If still no luck add:
gem 'rubysl-pty', :platforms => :ruby
gem 'web-console', :platforms => :ruby
then bundle install, rails c and let us know if that resolves your problem!
Alternatively, I would recommend using cloud9 or if you want to work locally on a rails app, and are using a Windows machine, try installing Linux/Unix...

Changing
gem 'web-console', '2.0.0.beta3'
to
gem 'web-console', '>= 2.0.0'
should make it work

Related

Installing Node using Brew fails

I ran brew install node it said Warning: The post-install step did not complete successfully You can try again using `brew postinstall node. I then ran brew postinstall --debug node and then it failed with:
An exception occurred within a child process:
Errno::EACCES: Permission denied # rb_sysopen - /usr/local/lib/node
/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/fileutils.rb:1386:in `initialize'
/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/fileutils.rb:1386:in `open'
/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/fileutils.rb:1386:in `block in copy_file'
/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/fileutils.rb:1385:in `open'
/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/fileutils.rb:1385:in `copy_file'
/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/fileutils.rb:1353:in `copy'
/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/fileutils.rb:478:in `block in copy_entry'
/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/fileutils.rb:1484:in `wrap_traverse'
/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/fileutils.rb:1487:in `block in wrap_traverse'
/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/fileutils.rb:1486:in `each'
/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/fileutils.rb:1486:in `wrap_traverse'
/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/fileutils.rb:475:in `copy_entry'
/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/fileutils.rb:453:in `block in cp_r'
/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/fileutils.rb:1557:in `block in fu_each_src_dest'
/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/fileutils.rb:1571:in `fu_each_src_dest0'
/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/fileutils.rb:1555:in `fu_each_src_dest'
/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/fileutils.rb:452:in `cp_r'
/usr/local/Homebrew/Library/Taps/homebrew/homebrew-core/Formula/node.rb:62:in `post_install'
/usr/local/Homebrew/Library/Homebrew/formula.rb:1036:in `block (2 levels) in run_post_install'
/usr/local/Homebrew/Library/Homebrew/formula.rb:891:in `with_logging'
/usr/local/Homebrew/Library/Homebrew/formula.rb:1035:in `block in run_post_install'
/usr/local/Homebrew/Library/Homebrew/utils.rb:474:in `with_env'
/usr/local/Homebrew/Library/Homebrew/formula.rb:1025:in `run_post_install'
/usr/local/Homebrew/Library/Homebrew/postinstall.rb:21:in `<main>'
When I run brew doctor it responds with:
Warning: Unbrewed header files were found in /usr/local/include.
If you didn't put them there on purpose they could cause problems when
building Homebrew formulae, and may need to be deleted.
Unexpected header files:
/usr/local/include/node/v8-testing.h
Warning: You have unlinked kegs in your Cellar.
Leaving kegs unlinked can lead to build-trouble and cause brews that depend on
those kegs to fail to run properly once built. Run `brew link` on these:
python
python#3.8
and when I run brew config it responds with:
HOMEBREW_VERSION: 2.4.4
ORIGIN: https://github.com/Homebrew/brew
HEAD: f455fe28a7a47b51af090b308e95535d6cf0a423
Last commit: 3 days ago
Core tap ORIGIN: https://github.com/Homebrew/homebrew-core
Core tap HEAD: 3e559ee9667cd55a21aa4bfaa50074cea090b4fb
Core tap last commit: 26 hours ago
HOMEBREW_PREFIX: /usr/local
HOMEBREW_MAKE_JOBS: 4
CPU: quad-core 64-bit kabylake
Homebrew Ruby: 2.6.3 => /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/bin/ruby
Clang: 11.0 build 1103
Git: 2.24.3 => /Applications/Xcode.app/Contents/Developer/usr/bin/git
Curl: 7.64.1 => /usr/bin/curl
Java: 14.0.1, 11.0.7, 1.8.0_252
macOS: 10.15.5-x86_64
CLT: 1103.0.32.59
Xcode: 11.5
I an running Mac OS Catalina. I tried uninstalling node and reinstalling node. I tried to give the necessary permission to brew, that didn't help either.
Can anyone help me?
Can you try brew reinstall node?
If that does not work, can you attach the brew doctor or brew config for debugging? Good luck!

GitLab CI pipeline fialing with You must use Bundler 2 or greater with this lockfile

I am trying to setup a simple test stage for my GitLab Rails project with a simple build script (below) and I am getting an error:
bundler: failed to load command: rspec (/usr/local/bundle/bin/rspec)
Bundler::LockfileError: You must use Bundler 2 or greater with this lockfile.
/usr/local/lib/ruby/gems/2.4.0/gems/bundler-1.14.6/lib/bundler/lockfile_parser.rb:108:in `warn_for_outdated_bundler_version'
/usr/local/lib/ruby/gems/2.4.0/gems/bundler-1.14.6/lib/bundler/lockfile_parser.rb:95:in `initialize'
/usr/local/lib/ruby/gems/2.4.0/gems/bundler-1.14.6/lib/bundler/definition.rb:72:in `new'
/usr/local/lib/ruby/gems/2.4.0/gems/bundler-1.14.6/lib/bundler/definition.rb:72:in `initialize'
/usr/local/lib/ruby/gems/2.4.0/gems/bundler-1.14.6/lib/bundler/dsl.rb:200:in `new'
/usr/local/lib/ruby/gems/2.4.0/gems/bundler-1.14.6/lib/bundler/dsl.rb:200:in `to_definition'
/usr/local/lib/ruby/gems/2.4.0/gems/bundler-1.14.6/lib/bundler/dsl.rb:12:in `evaluate'
/usr/local/lib/ruby/gems/2.4.0/gems/bundler-1.14.6/lib/bundler/definition.rb:33:in `build'
/usr/local/lib/ruby/gems/2.4.0/gems/bundler-1.14.6/lib/bundler.rb:128:in `definition'
/usr/local/lib/ruby/gems/2.4.0/gems/bundler-1.14.6/lib/bundler.rb:94:in `setup'
/usr/local/lib/ruby/gems/2.4.0/gems/bundler-1.14.6/lib/bundler/setup.rb:20:in `<top (required)>'
/usr/local/lib/ruby/site_ruby/2.4.0/rubygems/core_ext/kernel_require.rb:55:in `require'
/usr/local/lib/ruby/site_ruby/2.4.0/rubygems/core_ext/kernel_require.rb:55:in `require'
I am getting this error because they are using bundler bundler-1.14.6 in their build and my Gemfile lock has been bundled with bundler 2.0.2. Is there a way to install the requried version of bundler on GitLab build?
This is my simple test job (taken from GitLab docs).
image: "ruby:2.4.0"
before_script:
- apt-get update -qq && apt-get install -y -qq sqlite3 libsqlite3-dev nodejs
- ruby -v
- which ruby
- gem install bundler --no-document
- bundle install --jobs $(nproc) "${FLAGS[#]}"
rspec:
script:
- bundle exec rspec
P.S. I've signed up to GitLab forum but they never activated my account that's why I am posting my question here.
If you are using container registry, one possibility is to download docker image, use:
docker exec -itd container bash # look it up, can't check syntax right now
and then inside container perform upgrade, next will be docker commit and tag(also look it up) and then update container registry on gitlab

Try: gem pristine bootsnap --version 1.3.1 Ignoring bootsnap-1.3.1 because its extensions are not built. Try: gem pristine bootsnap --version 1.3.1

rails generate acts_as_votable:migration
Ignoring bootsnap-1.3.1 because its extensions are not built. Try: gem pristine bootsnap --version 1.3.1
Ignoring bootsnap-1.3.1 because its extensions are not built. Try: gem pristine bootsnap --version 1.3.1
/home/ayesha/.rvm/gems/ruby-2.2.1/gems/bundler-1.16.3/lib/bundler/definition.rb:491:in validate_ruby!': Your Ruby version is 2.2.1, but your Gemfile specified 2.5.1 (Bundler::RubyVersionMismatch)
from /home/ayesha/.rvm/gems/ruby-2.2.1/gems/bundler-1.16.3/lib/bundler/definition.rb:466:invalidate_runtime!'
from /home/ayesha/.rvm/gems/ruby-2.2.1/gems/bundler-1.16.3/lib/bundler.rb:101:in setup'
from /home/ayesha/.rvm/gems/ruby-2.2.1/gems/bundler-1.16.3/lib/bundler/setup.rb:20:in'
from /home/ayesha/.rvm/rubies/ruby-2.2.1/lib/ruby/site_ruby/2.2.0/rubygems/core_ext/kernel_require.rb:55:in require'
from /home/ayesha/.rvm/rubies/ruby-2.2.1/lib/ruby/site_ruby/2.2.0/rubygems/core_ext/kernel_require.rb:55:inrequire'
from /home/ayesha/.rvm/gems/ruby-2.2.1/gems/spring-2.0.2/lib/spring/commands.rb:33:in <module:Spring>'
from /home/ayesha/.rvm/gems/ruby-2.2.1/gems/spring-2.0.2/lib/spring/commands.rb:4:in'
from /home/ayesha/.rvm/rubies/ruby-2.2.1/lib/ruby/site_ruby/2.2.0/rubygems/core_ext/kernel_require.rb:55:in require'
from /home/ayesha/.rvm/rubies/ruby-2.2.1/lib/ruby/site_ruby/2.2.0/rubygems/core_ext/kernel_require.rb:55:inrequire'
from /home/ayesha/.rvm/gems/ruby-2.2.1/gems/spring-2.0.2/lib/spring/server.rb:9:in <top (required)>'
from /home/ayesha/.rvm/rubies/ruby-2.2.1/lib/ruby/site_ruby/2.2.0/rubygems/core_ext/kernel_require.rb:55:inrequire'
from /home/ayesha/.rvm/rubies/ruby-2.2.1/lib/ruby/site_ruby/2.2.0/rubygems/core_ext/kernel_require.rb:55:in require'
from /home/ayesha/.rvm/gems/ruby-2.2.1/gems/spring-2.0.2/lib/spring/client/server.rb:9:incall'
from /home/ayesha/.rvm/gems/ruby-2.2.1/gems/spring-2.0.2/lib/spring/client/command.rb:7:in call'
from /home/ayesha/.rvm/gems/ruby-2.2.1/gems/spring-2.0.2/lib/spring/client.rb:30:inrun'
from /home/ayesha/.rvm/gems/ruby-2.2.1/gems/spring-2.0.2/bin/spring:49:in `'
The error message is telling you what to do, though perhaps not very directly.
Try running this command:
gem pristine bootsnap --version 1.3.1
That will try to reinstall the bootsnap gem from scratch.

Jekyll installation, wrong number of arguments

I am running Fedora 28. Having trouble installing Jekyll. I have all the dependencies mentioned on their installation page.
ruby -v
ruby 2.5.1p57 (2018-03-29 revision 63029) [x86_64-linux]
gem -v
2.5.2
bundle -v
Bundler version 1.16.1
When I try to install Jekyll, I am getting this -
gem install jekyll
ERROR: While executing gem ... (ArgumentError)
wrong number of arguments (given 1, expected 0)
Running as root doesn't help either. When I run backtrace,
gem install jekyll --backtrace
ERROR: While executing gem ... (ArgumentError)
wrong number of arguments (given 1, expected 0)
/usr/local/share/ruby/site_ruby/rubygems/core_ext/kernel_require.rb:47:in `require'
/usr/local/share/ruby/site_ruby/rubygems/installer.rb:162:in `initialize'
/usr/local/share/ruby/site_ruby/rubygems/installer.rb:104:in `new'
/usr/local/share/ruby/site_ruby/rubygems/installer.rb:104:in `at'
/usr/local/share/ruby/site_ruby/rubygems/resolver/specification.rb:93:in `install'
/usr/local/share/ruby/site_ruby/rubygems/request_set.rb:166:in `block in install'
/usr/local/share/ruby/site_ruby/rubygems/request_set.rb:156:in `each'
/usr/local/share/ruby/site_ruby/rubygems/request_set.rb:156:in `install'
/usr/local/share/ruby/site_ruby/rubygems/commands/install_command.rb:250:in `install_gem'
/usr/local/share/ruby/site_ruby/rubygems/commands/install_command.rb:300:in `block in install_gems'
/usr/local/share/ruby/site_ruby/rubygems/commands/install_command.rb:296:in `each'
/usr/local/share/ruby/site_ruby/rubygems/commands/install_command.rb:296:in `install_gems'
/usr/local/share/ruby/site_ruby/rubygems/commands/install_command.rb:203:in `execute'
/usr/local/share/ruby/site_ruby/rubygems/command.rb:308:in `invoke_with_build_args'
/usr/local/share/ruby/site_ruby/rubygems/command_manager.rb:169:in `process_args'
/usr/local/share/ruby/site_ruby/rubygems/command_manager.rb:139:in `run'
/usr/local/share/ruby/site_ruby/rubygems/gem_runner.rb:55:in `run'
/usr/bin/gem:21:in `<main>'
I guess the ruby version was the problem. Once I installed ruby 2.4 using https://rvm.io/ installation was successful

foreman db import fails

I have installed foreman on centos 6, using the yum repo
[root#server roor]# cat /etc/yum.repos.d/foreman.repo
[foreman]
name=Foreman Repo
baseurl=http://yum.theforeman.org/releases/latest/el6/x86_64/
gpgcheck=0
enabled=1
and configured database.yml as
production:
adapter: mysql
database: foreman
username: foreman
password: xxxxxx
encoding: utf8
however while building the tables, gives this error, any ideas?
[root#server foreman]# sudo RAILS_ENV=production rake db:migrate
(in /usr/share/foreman)
rake aborted!
no such file to load -- rails/all
/usr/share/foreman/Rakefile:1
(See full trace by running task with --trace)
[root#serverforeman]#
UPDATED:
fixed using
[root#server foreman]# cat /opt/rh/ruby193/enable
export PATH=/opt/rh/ruby193/root/usr/bin:$PATH
export LD_LIBRARY_PATH=/opt/rh/ruby193/root/usr/lib64:$LD_LIBRARY_PATH
export MANPATH=/opt/rh/ruby193/root/usr/share/man:$MANPATH
but now its stuck on....
[root#server foreman]# RAILS_ENV=production rake db:migrate --trace
rake aborted!
undefined method `active_record' for #<Rails::Application::Configuration:0x00000003ad8358>
/opt/rh/ruby193/root/usr/share/gems/gems/railties-3.2.8/lib/rails/railtie/configuration.rb:85:in `method_missing'
/usr/share/foreman/config/application.rb:57:in `<class:Application>'
/usr/share/foreman/config/application.rb:37:in `<module:Foreman>'
/usr/share/foreman/config/application.rb:36:in `<top (required)>'
/opt/rh/ruby193/root/usr/share/rubygems/rubygems/custom_require.rb:36:in `require'
/opt/rh/ruby193/root/usr/share/rubygems/rubygems/custom_require.rb:36:in `require'
/usr/share/foreman/Rakefile:1:in `<top (required)>'
/opt/rh/ruby193/root/usr/share/ruby/rake/rake_module.rb:25:in `load'
/opt/rh/ruby193/root/usr/share/ruby/rake/rake_module.rb:25:in `load_rakefile'
/opt/rh/ruby193/root/usr/share/ruby/rake/application.rb:501:in `raw_load_rakefile'
/opt/rh/ruby193/root/usr/share/ruby/rake/application.rb:82:in `block in load_rakefile'
/opt/rh/ruby193/root/usr/share/ruby/rake/application.rb:133:in `standard_exception_handling'
/opt/rh/ruby193/root/usr/share/ruby/rake/application.rb:81:in `load_rakefile'
/opt/rh/ruby193/root/usr/share/ruby/rake/application.rb:65:in `block in run'
/opt/rh/ruby193/root/usr/share/ruby/rake/application.rb:133:in `standard_exception_handling'
/opt/rh/ruby193/root/usr/share/ruby/rake/application.rb:63:in `run'
/opt/rh/ruby193/root/usr/bin/rake:32:in `<main>'
FIXED:
currently foreman will have problems if there are multiple version of activerecord/ mysql installed, and one should use the gems supplied with the foreman installation.
so these were the steps to remove the unnecessary gems
scl enable ruby193 'gem list'
scl enable ruby193 'gem uninstall -v 4.0.0 activerecord'
gem uninstall -v 2.9.1 mysql
currently foreman will have problems if there are multiple version of activerecord/ mysql installed, and one should use the gems supplied with the foreman installation.
so these were the steps to remove the unnecessary gems
scl enable ruby193 'gem list'
scl enable ruby193 'gem uninstall -v 4.0.0 activerecord'
gem uninstall -v 2.9.1 mysql

Resources