I recently updated ruby from 2.1.5 to 2.6.10 with rbenv.
with the original rails 4.1.8 untouched.
when I run sudo -E RAILS_ENV=production rails s -p 80
it complains
/usr/local/lib/ruby/2.1.0/rubygems/core_ext/kernel_require.rb:55:in `require': cannot load such file -- bundler/setup (LoadError)
run
bundler -v
Bundler version 1.17.2
run
ruby -v
ruby 2.6.10p210 (2022-04-12 revision 67958) [x86_64-linux]
run
gem install bundler
Successfully installed bundler-2.3.23
but bundler -v remains 1.17.2
run RAILS_ENV=production rails s -p 80 throw different error. it seems ruby 2.6.10 is hooked, but
=> Booting WEBrick
=> Rails 4.1.8 application starting in production on http://0.0.0.0:80
=> Run `rails server -h` for more startup options
=> Notice: server is listening on all interfaces (0.0.0.0). Consider using 127.0.0.1 (--binding option)
=> Ctrl-C to shutdown server
/home/ubuntu/.rbenv/versions/2.6.10/lib/ruby/gems/2.6.0/gems/activesupport-4.1.8/lib/active_support/core_ext/numeric/conversions.rb:121: warning: constant ::Fixnum is deprecated
/home/ubuntu/.rbenv/versions/2.6.10/lib/ruby/gems/2.6.0/gems/activesupport-4.1.8/lib/active_support/core_ext/numeric/conversions.rb:121: warning: constant ::Bignum is deprecated
Exiting
/home/ubuntu/.rbenv/versions/2.6.10/lib/ruby/gems/2.6.0/gems/activesupport-4.1.8/lib/active_support/core_ext/numeric/conversions.rb:131:in `block (2 levels) in <class:Numeric>': stack level too deep (SystemStackError)
why with/without sudo invoke different version of ruby? and how to solve the systemstackerror?
Related
I have upgraded ruby version from 2.3.1 to 3.0.2 and also done related changes.
On server, after deployment, nginx server cant start and giving error for old version.
I have checked ruby version with login user in ubuntu and rvm list , new 3.0.2 version is set as default version.
Error log:
App 7441 stdout:
App 7441 stdout:
[ E 2021-10-19 03:59:51.9761 5027/T49 age/Cor/App/Implementation.cpp:304 ]: Could not spawn process for application /home/apprunner/application/current: An error occurred while starting up the preloader.
Error ID: c6399257
Error details saved to: /tmp/passenger-error-J6lyAl.html
Message from application: You must use Bundler 2 or greater with this lockfile. (Bundler::LockfileError)
/usr/local/rvm/gems/ruby-2.3.0#application/gems/bundler-1.11.2/lib/bundler/lockfile_parser.rb:72:in `warn_for_outdated_bundler_version'
/usr/local/rvm/gems/ruby-2.3.0#application/gems/bundler-1.11.2/lib/bundler/lockfile_parser.rb:59:in `initialize'
/usr/local/rvm/gems/ruby-2.3.0#application/gems/bundler-1.11.2/lib/bundler/definition.rb:61:in `new'
/usr/local/rvm/gems/ruby-2.3.0#application/gems/bundler-1.11.2/lib/bundler/definition.rb:61:in `initialize'
/usr/local/rvm/gems/ruby-2.3.0#application/gems/bundler-1.11.2/lib/bundler/dsl.rb:173:in `new'
/usr/local/rvm/gems/ruby-2.3.0#application/gems/bundler-1.11.2/lib/bundler/dsl.rb:173:in `to_definition'
/usr/local/rvm/gems/ruby-2.3.0#application/gems/bundler-1.11.2/lib/bundler/dsl.rb:11:in `evaluate'
/usr/local/rvm/gems/ruby-2.3.0#application/gems/bundler-1.11.2/lib/bundler/definition.rb:24:in `build'
/usr/local/rvm/gems/ruby-2.3.0#application/gems/bundler-1.11.2/lib/bundler.rb:120:in `definition'
/usr/local/rvm/gems/ruby-2.3.0#application/gems/bundler-1.11.2/lib/bundler.rb:88:in `setup'
/usr/local/rvm/gems/ruby-2.3.0#application/gems/bundler-1.11.2/lib/bundler/setup.rb:18:in `<top (required)>'
/usr/local/rvm/rubies/ruby-2.3.0/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require'
/usr/local/rvm/rubies/ruby-2.3.0/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require'
/usr/lib/ruby/vendor_ruby/phusion_passenger/loader_shared_helpers.rb:456:in `activate_gem'
/usr/lib/ruby/vendor_ruby/phusion_passenger/loader_shared_helpers.rb:323:in `block in run_load_path_setup_code'
/usr/lib/ruby/vendor_ruby/phusion_passenger/loader_shared_helpers.rb:461:in `running_bundler'
/usr/lib/ruby/vendor_ruby/phusion_passenger/loader_shared_helpers.rb:322:in `run_load_path_setup_code'
/usr/share/passenger/helper-scripts/rack-preloader.rb:100:in `preload_app'
/usr/share/passenger/helper-scripts/rack-preloader.rb:156:in `<module:App>'
/usr/share/passenger/helper-scripts/rack-preloader.rb:30:in `<module:PhusionPassenger>'
/usr/share/passenger/helper-scripts/rack-preloader.rb:29:in `<main>'
[ E 2021-10-19 03:59:51.9814 5027/T7 age/Cor/Con/CheckoutSession.cpp:285 ]: [Client 1-25] Cannot checkout session because a spawning error occurred. The identifier of the error is c6399257. Please see earlier logs for details about the error.
Don't know why error is show version 2.3.0?
How to set ruby version to passenger from rvm?
passenger check ruby command gives two different output:
Command: passenger-config about ruby-command
With Sudo user (rvm command not detected):
root#ip-:/usr/bin# passenger-config about ruby-command
passenger-config was invoked through the following Ruby interpreter:
Command: /usr/bin/ruby2.3
Version: ruby 2.3.1p112 (2016-04-26) [x86_64-linux-gnu]
To use in Apache: PassengerRuby /usr/bin/ruby2.3
To use in Nginx : passenger_ruby /usr/bin/ruby2.3
To use with Standalone: /usr/bin/ruby2.3 /usr/bin/passenger start
The following Ruby interpreter was found first in $PATH:
Command: /usr/bin/ruby
Version: ruby 2.3.1p112 (2016-04-26) [x86_64-linux-gnu]
To use in Apache: PassengerRuby /usr/bin/ruby
To use in Nginx : passenger_ruby /usr/bin/ruby
To use with Standalone: /usr/bin/ruby /usr/bin/passenger start
System user(login user where rvm command detected):
current$ passenger-config about ruby-command
Your RVM wrapper scripts are too old, or some wrapper scripts are missing. Please update/regenerate them first by running:
rvmsudo rvm get stable && rvm reload && rvmsudo rvm repair all
If that doesn't seem to work, please run:
rvmsudo rvm wrapper ruby-3.0.2 --no-prefix --all
Please provide any clue, how to set passenger ruby default version or how to solve this error.
As passenger is designed to server multiple (Rails) applications on one webserver, there are config options per virtual host (actually per dirctory) to set the environment for each application.
see https://www.phusionpassenger.com/docs/references/config_reference/apache/ and https://www.phusionpassenger.com/docs/references/config_reference/nginx/
RVM installs wrappers for each installed ruby in i.e. ~/.rvm/wrappers/ruby-3.0.2/ruby and you can tell passenger to use this ruby for your application.
in an apache config, you can write:
<Directory "/path/to/you/rails/app">
PassengerRuby "/home/your-user/.rvm/wrappers/3.0.2/ruby"
RailsEnv production
</Directory>
passenger-config tells you what wrapper to use, but you must set the ruby environment first. My passenger-config outputs this comment:
Notes for RVM users
Do you want to know which command to use for a different Ruby interpreter? 'rvm use' that Ruby interpreter, then re-run 'passenger-config about ruby-command'.
This question is related to this one, but the proposed solutons didn't work for me.
I'm trying to deploy a Rails 5.2 application with Ruby 2.6.1, but I keep getting this error in the deployment phase:
/app/vendor/bundle/ruby/2.6.0/gems/bundler-2.0.1/lib/bundler/lockfile_parser.rb:108:in `warn_for_outdated_bundler_version': You must use Bundler 2 or greater with this lockfile. (Bundler::LockfileError)
from /app/vendor/bundle/ruby/2.6.0/gems/bundler-2.0.1/lib/bundler/lockfile_parser.rb:95:in `initialize'
from /app/vendor/bundle/ruby/2.6.0/gems/bundler-2.0.1/lib/bundler/definition.rb:83:in `new'
from /app/vendor/bundle/ruby/2.6.0/gems/bundler-2.0.1/lib/bundler/definition.rb:83:in `initialize'
from /app/vendor/bundle/ruby/2.6.0/gems/bundler-2.0.1/lib/bundler/dsl.rb:234:in `new'
from /app/vendor/bundle/ruby/2.6.0/gems/bundler-2.0.1/lib/bundler/dsl.rb:234:in `to_definition'
from /app/vendor/bundle/ruby/2.6.0/gems/bundler-2.0.1/lib/bundler/dsl.rb:13:in `evaluate'
from /app/vendor/bundle/ruby/2.6.0/gems/bundler-2.0.1/lib/bundler/definition.rb:34:in `build'
from /app/vendor/bundle/ruby/2.6.0/gems/bundler-2.0.1/lib/bundler.rb:135:in `definition'
from /app/vendor/bundle/ruby/2.6.0/gems/bundler-2.0.1/lib/bundler.rb:101:in `setup'
from /app/vendor/ruby-2.6.1/lib/ruby/2.6.0/bundler/setup.rb:20:in `<top (required)>'
from /app/vendor/ruby-2.6.1/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in `require'
from /app/vendor/ruby-2.6.1/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in `require'
from /app/config/boot.rb:3:in `<top (required)>'
from /app/bin/rake:2:in `require_relative'
from /app/bin/rake:2:in `<main>'
What I find strange in this error is this line:
/app/vendor/bundle/ruby/2.6.0/gems/bundler-2.0.1/lib/bundler/lockfile_parser.rb:108:in `warn_for_outdated_bundler_version': You must use Bundler 2 or greater with this lockfile. (Bundler::LockfileError)
Heroku seems to say it is using Ruby 2.6.0. But in the build phase, it says it uses Ruby 2.6.1 with Bundler 2:
-----> Ruby app detected
-----> Compiling Ruby/Rails
-----> Using Ruby version: ruby-2.6.1
-----> Installing dependencies using bundler 2.0.1
The build is successful, but the deployment is in failure.
Here is how is configured my app.
Gemfile (reduced to what matters)
ruby "2.6.1"
gem 'rails', '~> 5.2'
Gemfile.lock (reduced to what matters)
RUBY VERSION
ruby 2.6.1p33
BUNDLED WITH
2.0.1
On heroku, my buildpack is heroku/ruby. My stack is heroku-18.
Heroku seems to be supporting Bundler 2, as said in this post.
Any idea on what could fail in the deployment?
I found a solution. The problem was at deploy time, not during the build. The deployment was using Ruby 2.6.0, because of Heroku's web dyno that is by default:
rails server -p $PORT -e $RAILS_ENV
Yet, this post from bundler github is telling to prefix every single command with bundle exec. But the rails server command from the dyno is not prefixed so.
A workaround I found is modifying the project Procfile file, and add the following line:
web: bundle exec rails server -p $PORT -e $RAILS_ENV
This way, the rails server command uses the expected Ruby version, the 2.6.1 insteand of the 2.6.0 that generated the error.
I'm using rvm on mac osx 10.9.5:
rvm 1.26.11 (latest) by Wayne E. Seguin , Michal Papis [https://rvm.io/]
Current ruby version in RVM:
=* ruby-2.2.3 [ x86_64 ]
I'm not sure what exactly caused this behaviour, it could be that I updated homebrew.
I also tried to disable spring by removing it from the gemfile, no luck. Also note the paths in the stacktrace, for Spring it points to 2.1.3 instead of 2.2.3. What could be going on here ?
$ rails c
Ignoring libv8-3.16.14.13 because its extensions are not built. Try: gem pristine libv8 --version 3.16.14.13
Ignoring libv8-3.16.14.11 because its extensions are not built. Try: gem pristine libv8 --version 3.16.14.11
Ignoring oj-2.14.0 because its extensions are not built. Try: gem pristine oj --version 2.14.0
/Users/Laurens/.rvm/rubies/ruby-2.2.3/lib/ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:in `require': cannot load such file -- bundler/setup (LoadError)
from /Users/Laurens/.rvm/rubies/ruby-2.2.3/lib/ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:in `require'
from /Users/Laurens/.rvm/gems/ruby-2.1.3/ruby/2.2.0/gems/spring-1.4.4/lib/spring/commands.rb:33:in `<module:Spring>'
from /Users/Laurens/.rvm/gems/ruby-2.1.3/ruby/2.2.0/gems/spring-1.4.4/lib/spring/commands.rb:4:in `<top (required)>'
from /Users/Laurens/.rvm/rubies/ruby-2.2.3/lib/ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:in `require'
from /Users/Laurens/.rvm/rubies/ruby-2.2.3/lib/ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:in `require'
from /Users/Laurens/.rvm/gems/ruby-2.1.3/ruby/2.2.0/gems/spring-1.4.4/lib/spring/application.rb:77:in `preload'
from /Users/Laurens/.rvm/gems/ruby-2.1.3/ruby/2.2.0/gems/spring-1.4.4/lib/spring/application.rb:143:in `serve'
from /Users/Laurens/.rvm/gems/ruby-2.1.3/ruby/2.2.0/gems/spring-1.4.4/lib/spring/application.rb:131:in `block in run'
from /Users/Laurens/.rvm/gems/ruby-2.1.3/ruby/2.2.0/gems/spring-1.4.4/lib/spring/application.rb:125:in `loop'
from /Users/Laurens/.rvm/gems/ruby-2.1.3/ruby/2.2.0/gems/spring-1.4.4/lib/spring/application.rb:125:in `run'
from /Users/Laurens/.rvm/gems/ruby-2.1.3/ruby/2.2.0/gems/spring-1.4.4/lib/spring/application/boot.rb:18:in `<top (required)>'
from /Users/Laurens/.rvm/rubies/ruby-2.2.3/lib/ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:in `require'
from /Users/Laurens/.rvm/rubies/ruby-2.2.3/lib/ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:in `require'
from -e:1:in `<main>'
$ rails s
=> Booting Thin
=> Rails 4.2.4 application starting in development on http://localhost:3000
=> Run `rails server -h` for more startup options
=> Ctrl-C to shutdown server
>> Thin web server (v1.5.1 codename Straight Razor)
>> Maximum connections set to 1024
>> Listening on localhost:3000, CTRL+C to stop
After lots of trial and error, got it working by doing the following:
In my rails project folder there was an invisible file called
".bundle", I deleted this file, it somehow had references to 2.1.3 .
Ran bundle install
Ran spring stop
Ran spring binstub --all
(In the meanwhile I also updated my xcode, but not sure if this had any effect.)
After this, rails c worked without the pristine & bundle errors.
Just update spring to latest (1.6.4)
see
https://github.com/rails/spring/issues/456
for references
have you tried this command?
gem pristine --all
If it does not help, try this one:
rvm get stable
You should also call your rails console command in the context of the bundle:
bunde exec rails console
I think I messed up one of my projects and now it won't run almost any command.
Initially I installed all through RVM. The Gemfile shows rails 4.1.3
After some time I think I may tried to update rails and started a couple of other projects which rails version is 4.2.0 and both run fine.
Recently I went back on the first project to deploy it. I was configuring Capistrano when I noticed that I couldn't run any development commands on my working machine. First I tried to run the server but this error appeared:
$ rails server
bin/rails:6: warning: already initialized constant APP_PATH
/home/axl/coding/bfq/bin/rails:6: warning: previous definition of APP_PATH was here
Usage: rails COMMAND [ARGS]
The most common rails commands are:
generate Generate new code (short-cut alias: "g")
console Start the Rails console (short-cut alias: "c")
server Start the Rails server (short-cut alias: "s")
dbconsole Start a console for the database specified in config/database.yml
(short-cut alias: "db")
new Create a new Rails application. "rails new my_app" creates a
new application called MyApp in "./my_app"
In addition to those, there are:
application Generate the Rails application code
destroy Undo code generated with "generate" (short-cut alias: "d")
plugin new Generates skeleton for developing a Rails plugin
runner Run a piece of code in the application environment (short-cut alias: "r")
All commands can be run with -h (or --help) for more information.
So I thought maybe I screw something with Capistrano so I returned to branch master but the error was still there.
Any rake call returns this:
$ rake db:setup
rake aborted!
Gem::LoadError: You have already activated rake 10.4.2, but your Gemfile requires rake 10.3.2. Prepending `bundle exec` to your command may solve this.
/home/axl/coding/bfq/config/boot.rb:4:in `<top (required)>'
/home/axl/coding/bfq/config/application.rb:1:in `<top (required)>'
/home/axl/coding/bfq fiscal-quadrum/Rakefile:4:in `<top (required)>'
LoadError: cannot load such file -- bundler/setup
/home/axl/coding/bfq/config/boot.rb:4:in `<top (required)>'
/home/axl/coding/bfq/config/application.rb:1:in `<top (required)>'
/home/axl/coding/bfq/Rakefile:4:in `<top (required)>'
(See full trace by running task with --trace)
Prepending bundle exec as suggested shows another error. For example:
$ bundle exec rake db:setup
rake aborted!
LoadError: cannot load such file -- gserver
/home/axl/coding/bfq/config/application.rb:7:in `<top (required)>'
/home/axl/coding/bfq/Rakefile:4:in `require'
/home/axl/coding/bfq/Rakefile:4:in `<top (required)>'
(See full trace by running task with --trace)
There are similar cases, error bin/rails:6: warning: already initialized constant APP_PATH is related to spring gem. Running rake rails:update:bin seems to help but I can't run it since rake doesn't work at all.
So I tried reinstalling RVM. But nothing changed. I even removed RVM and installed Rbenv. But everything is exactly the same.
Versions inside the project:
$ ruby --version
ruby 2.2.0p0 (2014-12-25 revision 49005) [x86_64-linux]
$ gem --version
2.4.5
$ rake --version
rake, version 10.4.2
$ rails --version
Rails 4.1.6
bundle update does some updates but after that executing rake shows the same error as prepending bundle exec:
$ rake
rake aborted!
LoadError: cannot load such file -- gserver
/home/axl/coding/bfq/config/application.rb:7:in `<top (required)>'
/home/axl/coding/bfq/Rakefile:4:in `<top (required)>'
(See full trace by running task with --trace)
And there is nothing useful googling LoadError: cannot load such file -- gserver
Please, help me :'(
Shame on me. I didn't define ruby local version for the project.
When using RVM:
$ rvm install 2.1.1
$ rvm use 2.1.1
For Rbenv:
$ rbenv install 2.1.1
$ rbenv local 2.1.1
What am i doing wrong? bundle install runs fine, ruby is at 1.9.3p194 (2012-04-20 revision 35410) [x86_64-darwin12.0.0]. Tried to replace psych with syck already but it throws the exact same errors.
rMBP:obtvse Tobias$ rails s
=> Booting Thin
=> Rails 3.2.0 application starting in development on http://0.0.0.0:3000
=> Call with -d to detach
=> Ctrl-C to shutdown server
Exiting
/Users/Tobias/.rbenv/versions/1.9.3-p194/lib/ruby/1.9.1/psych.rb:203:in `parse':
(<unknown>): found character that cannot start any token while scanning for the next
token at line 7 column 22 (Psych::SyntaxError)
from /Users/Tobias/.rbenv/versions/1.9.3-p194/lib/ruby/1.9.1/psych.rb:203:in
`parse_stream'
from /Users/Tobias/.rbenv/versions/1.9.3-p194/lib/ruby/1.9.1/psych.rb:151:in `parse'
from /Users/Tobias/.rbenv/versions/1.9.3-p194/lib/ruby/1.9.1/psych.rb:127:in `load'
from /Users/Tobias/Dropbox/obtvse/config/initializers/config.rb:1:in `<top (required)>'
from /Users/Tobias/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/activesupport-
(...)