I have started a project to update, which was updated also a couple of months ago, but today it's not running on the development, I have deleted Gemfile.lock and reinstall the gems & update the bundler but showing still.
Here are below I have attached the full specification of this project.
// Environment
$ ruby -v
- ruby 3.0.1p64 (2021-04-05 revision 0fb782ee38) [x86_64-darwin20]
$ rails -v
- Rails 5.2.6
$ bundle -v
- Bundler version 2.2.31
macOS v12.0.1
When running the rails server it's showing like this below
user#Users-MacBook-Pro max-domain % rails server
=> Booting Puma
=> Rails 5.2.6 application starting in development
=> Run `rails server -h` for more startup options
Exiting
/Users/user/.rbenv/versions/3.0.1/lib/ruby/gems/3.0.0/gems/activerecord-5.2.6/lib/active_record/type/adapter_specific_registry.rb:9:in `add_modifier': wrong number of arguments (given 3, expected 2) (ArgumentError)
.........
....
I don't even find any clue where can I fix that!
Would you please help me out with that?
Thanks
If you want Ruby 3.0.1 you need to be on Rails 6.1 (and above). Max ruby version for Rails 5.2 is 2.7.0.
Here's a compatibility table.
Related
rbenv ruby version: 2.6.6
rails version: 5.1.4
I am working within an older codebase (ruby: 2.6.6 | rails: 5.4.1). This is a codebase I work with daily. I had to download a new ruby version, through rbenv, for a separate repo and in doing so caused quite an issue in my dev environment for the older codebase.
My initial investigation of the issue that popped up led me to delete the rbenv ruby version I had for the older code base (2.6.6), re-install the ruby version, rehash then reinstall bundler.
Previously, I could just run rails command (rails c, rails s) to open the console or run the server. Now I am met with this error when trying to run a rails command:
rbenv: rails: command not found
The `rails' command exists in these Ruby versions:
2.3.1
When trying to open the rails console with the following commands, bundle exec rails console, bin/rails console, I am met with this error:
`preload': Spring only supports Rails >= 5.2.0 (RuntimeError)
After running bin/rails s, and opening the webpage, the console returns a 500 error:
Completed 500 Internal Server Error in 427ms (ActiveRecord: 0.9ms)
Error during failsafe response: couldn't find file 'ckeditor/init' with type 'application/javascript'
This isn't the exact answer to your question, but the workaround I did for the "Spring only supports Rails >= 5.2.0" was to just create a new project with rails 5.2.3 or something.
If you want to do the same, you can first list all your local gems by doing gem list rails --local
You will see all your rails versions installed locally.
Then do gem install rails -v '5.2.3'
Now go to a new project directory and run rails _5.2.3_ new appname
Now, you should be able to use the console, generate, migrate and other commands.
You can do bundle install after adding other relevant gems based on your apps requirement.
Despite answers like these: rails s or bundle exec rails s
and blog posts like these: https://www.wyeworks.com/blog/2011/12/27/bundle-exec-rails-executes-bundler-setup-3-times/
which all seem to indicate you should simply run rails s rather than bundle exec rails s I still find that occasionally I can't simply run rails s. E.g.
$ rails s
Rails is not currently installed on this system. To get the latest version, simply type:
$ sudo gem install rails
You can then rerun your "rails" command.
Whereas running this immediately afterwards in the same environment:
$ bundle exec rails s
=> Booting WEBrick
=> Rails 4.0.0.beta1 application starting in development on http://0.0.0.0:3000
=> Call with -d to detach
=> Ctrl-C to shutdown server
[2015-01-28 12:31:48] INFO WEBrick 1.3.1
[2015-01-28 12:31:48] INFO ruby 2.0.0 (2014-11-13) [x86_64-darwin14.0.0]
[2015-01-28 12:31:48] INFO WEBrick::HTTPServer#start: pid=18959 port=3000
Why is it not the same? Should this behaviour be fixed and, if so, how?
==== UPDATE
In response to #awendt
$ which rails
/Users/snowcrash/.rvm/gems/ruby-2.0.0-p598/bin/rails
$ rails c
Rails is not currently installed on this system. To get the latest version, simply type:
$ sudo gem install rails
You can then rerun your "rails" command.
$ bundle exec rails c
Loading development environment (Rails 4.0.0.beta1)
2.0.0-p598 :001 >
Trying to reproduce this, I get (on Ubuntu 12.04.5 LTS):
me#machine:/some/path$ rails c
The program 'rails' is currently not installed. To run 'rails' please ask your administrator to install the package 'rails'
me#machine:/some/path$ which rails
me#machine:/some/path$
So in my case, the rails script is not in my $PATH.
Your setup is different because the message explicitly mentions gems. You might even get this:
you#machine:/some/path$ which rails
/usr/bin/rails
you#machine:/some/path$
because /usr/bin/ is in your $PATH somewhere before other things and you're still invoking the rails script that ships with the OS.
Anyway, the important part is: bundle exec rails c lets Bundler figure out where to find the Rails gem, instead of letting the shell figure it out.
You may install gem into a completely arbitrary location, where only Bundler can find them because that location is not in your $PATH but in your $BUNDLE_PATH (see list of available keys for bundle config).
That's why rails and bundle exec rails are not the same.
This is not an error, and the behavior should not be fixed. Yes, you shouldn't have to run bundle exec rails because in recent versions, rails does the exact same thing. But the error you're seeing is a different issue.
For Rails 3x and above,whenever you are running the rails server,its always in context of the your environment and your Gemfile.So bundler helps in this regards to start and load the required gems/libraries using $BUNDLE_PATH for starting the application which by default wont be there if your are not using bundle exec instead it includes only the default libraries/gems using gemset(if you are using rvm) OR default path to load.
..hope this helps
After upgrading a Rails application to use Ruby 2.0.0 (from 1.9.3), I started receiving this error when attempting to deploy to Heroku via rake <stage> deploy.
Your Ruby version is 1.9.3, but your Gemfile specified 2.0.0 (Bundler::RubyVersionMismatch)
It also seems to cause this error, (but I can run the Heroku commands manually without the heroku_san helpers, so authorization is not the issue).
Expected(200) <=> Actual(401 Unauthorized)
I updated the gems to the latest version, and also updated the Heroku Toolbelt.
I found this pull request and patched my version, but the error persisted.
How do I solve this (on both Ubuntu & OSX)?
Other info:
Ubuntu 12.04 LTS x64
Rails 3.2.13
Ruby 2.0.0-p247
heroku-api-0.3.15
heroku_san-4.0.8
heroku-toolbelt/2.41.0 (x86_64-linux)
rvm 1.22.10
The solution for me on Ubuntu was to modify
/usr/local/heroku/bin/heroku
And change the shebang line to
#!/usr/bin/env ruby
Thanks goes to Pivotal Labs for this.
(I don't use a Mac.)
Another issue I found with this error (1.9.2 not 1.9.3) is having BUNDLE_GEMFILE env variable set on heroku which causes heroku ruby build pack to freak and default to 1.9.2.
This must be a simple question, but I could not find the answer by browsing this forum.
When I check rails version, it shows version 3.2.8
user#domain.com [~/rails_apps]# rails -v
Rails 3.2.8
user#domain.com [~/rails_apps]#
But when I start the server, it runs version 2.3.11
user#domain.com [~/rails_apps/myapp]# script/server -p12011
=> Booting Mongrel
=> Rails 2.3.11 application starting on http://0.0.0.0:12011
/home3/user/rails_apps/myapp/config/environment.rb:45: warning: already initialized constant RAILS_ENV
NOTE: SourceIndex.new(hash) is deprecated; From /usr/lib64/ruby/gems/1.8/gems/rails-2.3.11/lib/rails/vendor_gem_source_index.rb:100:in `new'.
=> Call with -d to detach
=> Ctrl-C to shutdown server
What am I doing wrong?
If you application is a 2.x rails application, you need to complete some changes before upgrade to 3.x
You may have a look to railscast http://railscasts.com/?tag_id=27
On the other hand, you may want to upgrade your ruby to 1.9 using rvm
rails 3.x work better with ruby 1.9
Try following in your environment.rb
RAILS_GEM_VERSION = '3.2.8' unless defined? RAILS_GEM_VERSION
Check your Gemfile and make sure it is pointing to rails 3.2.8
Then run bundle or bundle update
I wonder if this is an old app, built originally upon rails 2.3.1 and periodically upgraded insitu. Instead of script/server, try rails server
And make sure your Gemfile contains reference to rails 3.2.8
I'm not sure exactly what I did but I messed up the Ruby/gem harmony trying to get an older 2.3.5 Rails app working on my system.
I'm currently using Ruby 1.9.2-p0 and rubygems 1.5.7. I've tried the newest one 1.8.2 but it just generates more warnings. I use these alongside of RVM.
I get "can't convert Symbol into Integer" when trying to boot a 2.3.x Rails app no matter what version of rubygems I run. I tried 1.5.7, 1.7.2, and 1.8.2.
$ script/server
=> Booting WEBrick
=> Rails 2.3.5 application starting on http://0.0.0.0:3000
path/.rvm/gems/ruby-1.9.2-p0/gems/rails-2.3.5/lib/rails/gem_dependency.rb:51:in `[]': can't convert Symbol into Integer (TypeError)
Any idea how I can get my system back in harmony?
As Dex and The Tin Man suggested in the comments, the solution was to run rails 2 on ruby 1.8.7 and rails 3 on ruby 1.9.2 using vrm. The warnings generated by rubygems 1.8.2 (now 1.8.3) are solved by running his suggest commands.