How to fix bundler missing /usr/bin/ruby-mri (LoadError)? - ruby-on-rails

I am executing the following line to test the installation of redmine-3.3:
bundle exec ruby script/server webrick -e production
> /usr/bin/ruby-mri: No such file or directory -- script/server (LoadError)
Apparently, the executable ruby-mri is missing. Does anyone know how I can fix this? I am running Fedora24. Installed ruby with dnf install rubygem-rails.
I installed ruby with dnf install ruby, now the file is present, but the error message stays the same. So there is a file /usr/bin/ruby-mri, but the error message complaints the file is not present. ???

It is the wrong command. script/server is outdated. Use instead:
bundle exec rails server webrick -e production

Related

How to fix 'Please run rails webpacker: install Error: No such file or directory # rb_sysopen"?

I am attempting to create my first Ruby on Rails application following the documentation outlined on the website. When I attempted to run the server with 'rails server' from the cmd line I receive this error...
C:/Ruby/rubyinstaller-2.5.5-1-x64/rubyinstaller-2.5.5-1-x64/lib/ruby/gems/2.5.0/gems/webpacker-4.0.7/lib/webpacker/configuration.rb:91:in `rescue in load': Webpacker configuration file not found C:/Users/{username}/Desktop/Projects/Ruby on Rails/Blog Application/blog/config/webpacker.yml. Please run rails webpacker:install Error: No such file or directory # rb_sysopen - C:/Users/{username}/Desktop/Projects/Ruby on Rails/Blog Application/blog/config/webpacker.yml
OS: Windows 10
Yarn version: 1.17.3
Node.js version - v10.15.3
Rails version - 6.0.0
Ruby version - Ruby 2.5.5p157 (2019-03-15 revision 67260) [x64-mingw32]
sqlite3 version - 3.22.0
I expect for the server to run successfully and to open localhost:3000 to Yay! You're on rails
You may want to install yarn and then recreate your application if rails webpacker:install doesn't work.
I bit late, hopefully it helps someone using Linux:
Run:
bundle exec rails webpacker:install
That should fix the issue but in case you get the following the error:
superclass mismatch for class Command (TypeError)
run:
sudo dpkg -r --force-depends ruby-thor
sudo gem install thor
And then run again:
bundle exec rails webpacker:install

running Rails 5.1 console in production

I installed a Rails 5.1 app on a Ubuntu 14.04 server.
I have to run a rails console
so I changed directory to cd /opt/www/myapp/current
and entered the command:
rails c production
but then I get this error message:
The program 'rails' can be found in the following packages:
* ruby-railties-3.2
* ruby-railties-4.0
Try: sudo apt-get install
I tried to run the command with bundle:
bundle exec rails c production
but then I get this error message:
Undefined local variable or method `git_source' for Gemfile
from /opt/www/myapp/releases/20171017091250/Gemfile:3
I'm not sure what's going on.
Can someone help me run rails console on my production server?
Thanks a lot,
Anthony
Undefined local variable or method `git_source' for Gemfile
Or to save you visiting the link, try:
gem update bundler
git_source was added in bundler 1.6
found the issue, I needed to run the command
bundle exec rails c production
as the 'deploy' user

Received odd RVM error in workspace, now rails commands aren't working

I just logged into my Ubuntu workspace on Cloud9. Upon logging in I saw an error.
RVM used your Gemfile for selecting Ruby, it is all fine - Heroku does
that too, you can ignore these warnings with 'rvm rvmrc warning ignore
/home/ubuntu/workspace/Simutronix/Gemfile'. To ignore the warning for
all files run 'rvm rvmrc warning ignore allGemfiles'.
Which I've not seen before and wasn't occurring when I last used the workspace. I then attempted to run the Rails server.
rails server -b $IP -p $PORT
I got an error message back.
bash: rails: command not found
I then tried to run bundle install which also came back with command not found.
ruby -v returns ruby 2.4.1p111 (2017-03-22 revision 58053) [x86_64-linux].
What's likely to have happened to cause this to happen in between logins and what can I do to fix it?
Looks like Ubuntu can't find your Rails installation. Make sure you have Rails installed on your workspace by typing:
rails -v
If it is properly installed, It should return something like
Rails 5.0.2
(depending upon your Rails version.)
If you don't have Rails installed, you can install it by typing
gem install rails
You can append --no-doc to the above command if you don't want it to install documentation, thereby speeding up the installation process (That's totally up to you, though. It won't affect your installation in any other way. I promise!)
If this doesn't solve your problem, please update your answer with your Gemfile.
Likely the Ruby version defined in your Gemfile and/or .ruby-version changed, which means you will have to install bundler and bundle the gems again. Running this should solve the issue:
gem install bundler
bundle install

Why is `bundle exec rails s` not the same as `rails s`?

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

Rails3 Console Command not working

I was able to run rails console in a rails directory fine, however I ran into a problem running rails console --sandbox where I was getting an error like this:
no such file to load -- readline (LoadError)
After running this command: sudo apt-get install libncurses5-dev libreadline5-dev
(found here http://pranshuarya.com/jaal/Development/rails-3-error-require-no-such-file-to-load-readline-loaderror.html)
I now receive the following error when running either rails console or rails console --sandbox:
Could not find mail-2.2.16 in any of the sources
I am running Ubuntu 10.10, Ruby 1.9.2 and Rails 3
Any ideas?
I think that you could be having some gem in your gemfile but you did not run bundle install to install it. Please check that out.

Resources