Issue With Starting Rails Server & Creating a New Rails Project - ruby-on-rails

I am new to rails and have finally been able to install rails and follow along with a video tutorial. I am having a couple issues. Yesterday I was not having any major issues. Then this morning when I tried to create another rails project I get an error or when I try to run my rails server for my last first project I get an error. Any help would be greatly appreciated. Thank you!
/Users/lipmanb/.rvm/gems/ruby-2.0.0-p643/bin/rails:23:in `load': cannot load such file -- /Users/lipmanb/.rvm/gems/ruby-2.0.0-p643/gems/rails-4.2.3/bin/rails (LoadError)
from /Users/lipmanb/.rvm/gems/ruby-2.0.0-p643/bin/rails:23:in `<main>'
from /Users/lipmanb/.rvm/gems/ruby-2.0.0-p643/bin/ruby_executable_hooks:15:in `eval'
from /Users/lipmanb/.rvm/gems/ruby-2.0.0-p643/bin/ruby_executable_hooks:15:in `<main>'.

It looks like you don't have Rails installed on that environment. You may have installed Rails system wide, but since you are using RVM and you are within a Rails folder, you may be missing that specific Rails version.
Run bundler from within the Rails folder and install the required version.
$ bundler install
or simply
$ bundler

Navigate to your root directory cd ~ and type the following:
sudo gem install rails

Related

Impossible to execute rails s | railties-5.2.3/exe/rails (LoadError)

I can't launch my server with the command rails s, I have to use the command bundle exec rails s, but I prefer use the command rails s
Error when I launch the command rails s
Traceback (most recent call last):
1: from /home/leopaul/.rbenv/versions/2.5.1/bin/rails:23:in `<main>'
/home/leopaul/.rbenv/versions/2.5.1/bin/rails:23:in `load': cannot load such file -- /home/leopaul/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/railties-5.2.3/exe/rails (LoadError)
My rails version is :
Rails 5.1.6.2
I think you have multiple Rails versions installed in your machine.
Sometimes when you install a gem it comes with an executable/binary as well. Examples of these include: rails, rake, rspec, pry, etc. However, when you have multiple versions of a gem installed you then will have multiple versions of these executables sitting around. So if you want to execute one of these binaries for a given rails app you may need to disambiguate which executable you want -- the one for rake v10.1 or the one for rake v10.2, for example.
So for most commands you'll want to run bundle exec to make sure you're running the right version for your project (and also to make sure that all dependencies are also loaded from the correct versions specified in your Gemfile.lock).
So answering to your question if you are able to do bundle exec rails s and unable to do rails s try reinstalling rails gem to your local machine.
gem install rails
then check current version by rails -v
I would just like to add that in my case rubygems wasn't installed.
Running sudo apt-get install rubygems solved the issue!
See docs: http://railsapps.github.io/updating-rails.html
It seems that you have installed globally is rails 4 or some other rails version and it's the reason "it doesn't execute rails s" like you say because it consider default(global rails version) rails. When you run bundle exec then it uses the rails commands from the current Gemfile, since you have rails 5 in your Gemfile then it works properly.
Also try to create gemsets for every project.
In case your case, try this:
bundle update
then excecute
rails s
Hope it will work :)

copies a rails app to a new computer: rails command not found

I have just set up ruby and rails on a freshly installed freeBSD. It works great. I can do rails new blabla mv into blabla and do rails s and it just works.
I had an up and running rails app on another computer. I copied the repertory that contained the app to the new computer running freeBSD. However, when I mv into that repertory of the rails app and to rails server I get -bash: rails: command not found
I have tried creating a new app with the same name and let rails create all the repertories and then copy the files of the existing rails app therein but no success.
I can run rails -v and rails s from within any repertory and get correct answer, but when I move into that specific repertory I get that command not found.
You're probably using a ruby version manager I suspect (rbenv/rvm)? Check the ruby version in your Gemfile (top of the file). It probably isn't the same as the ruby version you have installed. If you're using one of the above mentioned version managers than install the correct ruby for your rails project. After that you can do a gem install bundler in the project directory and after run bundle install which will install rails and all dependencies.
Which version you are using? It happens with earlier versions. Try updating your gems and bundler. And try again. Hope it helps.
Did you try running bin/rails s? I think tha you need run bundle install too.

Rails new app display error

I am trying to create new project using rails but it display error. I am working on mac and its display error.
$rails new EMS
/Users/.rvm/gems/ruby-2.2.0/bin/rails:23:in `load': cannot load such file -- /Users/.rvm/gems/ruby-2.2.0/gems/rails-4.2.0/bin/rails (LoadError)
from /Users/.rvm/gems/ruby-2.2.0/bin/rails:23:in `<main>'
from /Users/.rvm/gems/ruby-2.2.0/bin/ruby_executable_hooks:15:in `eval'
from /Users/.rvm/gems/ruby-2.2.0/bin/ruby_executable_hooks:15:in `<main>'
One day i also faced same issue when i was trying to create new rails application. So followed these below steps and it was soled,
Uninstall the rails
Uninstall the ruby
Again install the latest version of ruby using rvm
than install the rails using command gem install rails
After following these step, now i am able to create new app. May be this also help you to solve this error.
If you are using windows OS as your development environment then please see this link : "certificate verify failed" error when installing Ruby gems on Windows
And I would recommend you to use : http://railsinstaller.org/en
By the way , Brother , Rails would behave perfect with Linux based platform .
And for mac os please take a look at : https://rvm.io/rvm/install
This will help you to have multiple ruby version and to switch between them ... to use full power of ruby and gems.

Rails - script/server boot up

Can someone help me out with something seemingly simple? My newness to Ruby on Rails is the reason, no doubt. I cannot start up the server. It looks like the boot file cannot be located but I'm nor sure at all.
There are several versions of ruby here, related to installing rvm:
which -a ruby
/Users/me/.rvm/rubies/ruby-1.9.3-p327/bin/ruby
/Users/me/.rvm/bin/ruby
/usr/local/bin/ruby
/usr/bin/ruby
Probably need to remove some?
Using Rails 3.2.9 with Ruby 1.9.3 on a Mac Mini
Thanks!
cd [rails project dir]
$ script/server
/Users/me/.rvm/rubies/ruby-1.9.3-p327/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require':
cannot load such file -- script/../config/boot (LoadError)
from /Users/me/.rvm/rubies/ruby-1.9.3-p327/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
from script/server:2:in `'
This isn't the issue you are getting. script/server still works, what you are experiencing is an issue with the gems you are trying to use. What you might try is running rails s --trace, see what gems are causing the issue and manually reinstalling them. From the looks of it, it's just an issue with a lone gem with dependencies in 1.9.1.
With Rails 3+ you get access to the rails command line scripts so instead of calling script/server you just run rails server or rails s for short.

`require': cannot load such file on running rails --help on brand new install

This is getting quite frustrating. I've eventually resorted to completely removing RVM, and reinstalling from scratch, as a normal user, so restricted to my /home.
After reinstall, I've run gem update --system and gem install rails.
Then I run rails --help, and get the following error:
rails --help
/home/anthony/.rvm/rubies/ruby-1.9.3-p0/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require': cannot load such file -- /home/anthony/config/boot (LoadError)
from /home/anthony/.rvm/rubies/ruby-1.9.3-p0/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
from script/rails:5:in `<main>'
Apparently rails thinks it should be loading a file /home/anthony/config/boot. It looks like the load path is screwed.
I've searched this out, and most people getting this error solve it with gem update --system (which I've one as above), or can at lest run rails -- or rails new . None of these work.
Final System info:
https://gist.github.com/1424644
Please help!
This may be totally a red herring, but it looks like your rails is in a different gemset - "campingground" - than either gem or ruby, which are in your default gemset. I'm not sure if this will cause the issue you're seeing or not - I believe it's OK if you're using the campingground gemset rvm use ruby-1.9.3-p0#campingground, but not if you're using the default gemset rvm use ruby-1.9.3-p0 because I believe that gemsets all inherit the default gemset, but not vice versa. I've had some issues with the bin launchers of ruby helpers (like the rails command) barfing all sorts of confusing load errors, which are often this very issue. Again, not sure if helpful, but I'd share that shot in the dark.

Resources