Ruby Ruby on Rails 5 Basics Creating an App Creating a Rails App

Purvi Agrawal
Purvi Agrawal
7,960 Points

ruby bin\rails server not working

Hi,

I have rails 5 and using the command "ruby bin\rails server" to run rails server as mentioned in the video. But I get the following error :

C:\RailsInstaller\Ruby2.2.0\bin\ruby.exe: No such file or directory -- binrails (LoadError)

Any inputs on what's wrong. I have Windows and have used Railsinstaller to install ruby and rails

Ethan Rivas
Ethan Rivas
9,972 Points

Hi! Are you trying to run the command inside the rails project folder?

14 Answers

Ethan Rivas
Ethan Rivas
9,972 Points

Ok, let's see:

  • First of all the command that you're running (if it's ruby bin/rails server) is wrong, the correct command you should be running is bin/rails server (I saw that you're working on windows so you can Ignore this).

  • Secondly this command have to be run inside the rails project directory (but you already told me that you are inside).


Maybe the problem is the command that are you trying to run is not the correct, but, the error says that you're not inside a rails project folder, so that's weird.

  • Try creating a new rails project typing:

rails new new_project

  • Go to your project folder:

cd new_project

  • After that try again:

bin/rails server (in your case ruby bin/rails server)

Purvi Agrawal
Purvi Agrawal
7,960 Points

@Ethan Rivas bin/rails server worked this time. I was using ruby bin\rails because it was mentioned in the video.

Thanks a lot for your help :)

Jay McGavren
STAFF
Jay McGavren
Treehouse Teacher

Purvi Agrawal , I suspect the difference is that you originally installed using Rails Installer, and you're still launching a command prompt/terminal that came with Rails Installer. It seems likely that commands will work differently there.

First:

  • Change into your Rails app directory.

Then, I would try the following things, in order. Some of them will probably fail. Continue using the first one that works:

  • Run bundle exec rails server
  • Run rails server
  • Run ruby bin/rails server (Note that's a forward slash, not a backslash.)
  • Run bin/rails server

I would appreciate it if you would reply here and let me know which one, if any, works for you. Even better would be if you copy and paste the commands and their output, including the ones that failed and the one that eventually works.

Purvi Agrawal
Purvi Agrawal
7,960 Points

Ethan Rivas Yes. I changed the directory to my rails app and then run the command. Should I do it outside the rails project folder ?

Ethan Rivas
Ethan Rivas
9,972 Points

Purvi Agrawal Yes, you have to be inside your project folder before you run the command, do you have the same error if you run this command: rails s ?

Purvi Agrawal
Purvi Agrawal
7,960 Points

No. rails s works perfectly fine for me. Its just the ruby bin\rails server giving an issue.

Ethan Rivas
Ethan Rivas
9,972 Points

Purvi Agrawal Can you run this command bundle install --binstubs and after that try again?

Purvi Agrawal
Purvi Agrawal
7,960 Points

I did. And then I ran the command again. This is the error I got :

$ ruby bin\rails server C:\RailsInstaller\Ruby2.2.0\bin\ruby.exe: No such file or directory -- binrails (LoadError)

Ethan Rivas
Ethan Rivas
9,972 Points

Purvi Agrawal What about rake rails:update:bin?

Purvi Agrawal
Purvi Agrawal
7,960 Points

@Ethan Rivas Is rake supported in rails 5 and higher ? I think its deprecated !

Ethan Rivas
Ethan Rivas
9,972 Points

Yes, it's deprecated, sorry, now is bin/rails or simple rails Edit: but I think that you can still using kt because I just try It in a New project with Rails 5

Purvi Agrawal
Purvi Agrawal
7,960 Points

@Ethan Rivas Can you please tell me y did u ask me to install binstubs ?

Ethan Rivas
Ethan Rivas
9,972 Points

Well, that helps me when I used to have that issue in my Rails project the last week.

Purvi Agrawal
Purvi Agrawal
7,960 Points

@Ethan Rivas Ok. But I am just trying to understand the significance of that command. Any idea what it helps with ?

Purvi Agrawal
Purvi Agrawal
7,960 Points

@Ethan Rivas Also is it possible to revert the changes it made ?

Ethan Rivas
Ethan Rivas
9,972 Points

Yes, this command is gonna generate files in your bin folder, those come from your gems, if you're using a workflow like git you can simple go back in "time"

Purvi Agrawal
Purvi Agrawal
7,960 Points

@Ethan Rivas Cool. Thanks !

Ethan Rivas
Ethan Rivas
9,972 Points

Np :), Now, going back to your first question, something fix it?

Purvi Agrawal
Purvi Agrawal
7,960 Points

@Ethan Rivas Nope. I tried the commands. Getting the same error.

Jay McGavren
STAFF
Jay McGavren
Treehouse Teacher

Purvi Agrawal , out of curiosity, what version of Windows are you running?

By the way, at the time of this reply, Rails Installer came with Rails 4.2, not Rails 5. So while it should work on Build a TODO List Application With Rails 4, things won't match up exactly with Rails 5 Basics. Just something to be aware of.

Purvi Agrawal
Purvi Agrawal
7,960 Points

Jay McGavren Hi Jay,

I am using Rails 5. I updated my rails version using bundle install after modifying the Gem File. But I am still facing the same issue.

Purvi Agrawal
Purvi Agrawal
7,960 Points

Hi Jay,

I am using the git bash command prompt. I installed it separately. I am in my rails app directory and interestingly all the above mentioned command works !

Jay McGavren
Jay McGavren
Treehouse Teacher

Purvi Agrawal , ah, that's an important detail! The ruby bin\rails command is actually meant for use in an ordinary Windows command prompt. Because you're running in Bash, you will generally want to use the commands meant for Mac or Linux users (who will also be running Bash), NOT commands meant for Windows users.

I think you'll be better off with your current setup in the long term. But that's something you'll need to keep in mind.

Purvi Agrawal
Purvi Agrawal
7,960 Points

Jay McGavren Thanks a lot Jay for taking out time and making me aware of the silly mistake I was doing ! A lesson learnt well for the future :)

Jay McGavren
Jay McGavren
Treehouse Teacher

Eylon Cohen try deleting the folder where you installed the DevKit (running rmdir C:\RubyDevKit /s in a Command Prompt window will probably do it) before trying to install again.

Eylon Cohen
Eylon Cohen
4,779 Points

Hello, I get something different - "Could not find gem 'sqlite3 X86-mingw32' in any of the gem sources listed in your Gemfile Run 'bundle install' to install missing gems."

I looked for this specific gem and installed it, and got a message telling me about the missing gem 'puma (~> 3.) x86 mingw 32.

bundle install does not deliver an error message but does not help as well. bundle exec rails server gives the same "Could not find gem" error message.

what am i missing?

I am working on windows and swiching 'bin/' with 'ruby bin\'

thank you :)

Jay McGavren
Jay McGavren
Treehouse Teacher

Hi Eylon Cohen , did you install Ruby and Rails following the directions here? If not, I would recommend uninstalling Ruby and reinstalling following those directions.

Eylon Cohen
Eylon Cohen
4,779 Points

Yes. I uninstall, redownload and reinstalled.. But I made it worse... now I cant install rails. I get this message:

Temporarily enhancing PATH to include DevKit...
Building native extensions.  This could take a while...
ERROR:  Error installing rails:
        ERROR: Failed to build gem native extension.

    C:/Ruby22/bin/ruby.exe -r ./siteconf20171120-7976-oqdipd.rb extconf.rb
creating Makefile

make "DESTDIR=" clean
'make' is not recognized as an internal or external command,
operable program or batch file.

make "DESTDIR="
'make' is not recognized as an internal or external command,
operable program or batch file.

make failed, exit code 1

Gem files will remain installed in C:/Ruby22/lib/ruby/gems/2.2.0/gems/websocket-driver-0.6.5 for inspection.
Results logged to C:/Ruby22/lib/ruby/gems/2.2.0/extensions/x86-mingw32/2.2.0/websocket-driver-0.6.5/gem_make.out
Eylon Cohen
Eylon Cohen
4,779 Points

Jay McGavren , got back to the original problem:

Could not find gem 'sqlite3 x86-mingw32' in any of the gem sources listed in your Gemfile. Run bundle install to install missing gems.

bundle install would give me:

The dependency byebug (>= 0) will be unused by any of the platforms Bundler is installing for. Bundler is installing for x86-mingw32 but the dependency is only for ruby. To add those platforms to the bundle, run bundle lock --add-platform ruby. Fetching gem metadata from https://rubygems.org/........... Fetching gem metadata from https://rubygems.org/.. Resolving dependencies...... Fetching rake 12.3.0 Installing rake 12.3.0 Using concurrent-ruby 1.0.5 Using i18n 0.9.1 Fetching minitest 5.10.3

Retrying download gem from https://rubygems.org/ due to error (2/4): Gem::RemoteFetcher::FetchError SSL_connect returned=1 errno=0 state=SSLv3 read server certificate B: certificate verify failed (https://rubygems.org/gems/minitest-5.10.3.gem) Retrying download gem from https://rubygems.org/ due to error (3/4): Gem::RemoteFetcher::FetchError SSL_connect returned=1 errno=0 state=SSLv3 read server certificate B: certificate verify failed (https://rubygems.org/gems/minitest-5.10.3.gem) Retrying download gem from https://rubygems.org/ due to error (4/4): Gem::RemoteFetcher::FetchError SSL_connect returned=1 errno=0 state=SSLv3 read server certificate B: certificate verify failed (https://rubygems.org/gems/minitest-5.10.3.gem) Gem::RemoteFetcher::FetchError: SSL_connect returned=1 errno=0 state=SSLv3 read server certificate B: certificate verify failed (https://rubygems.org/gems/minitest-5.10.3.gem) An error occurred while installing minitest (5.10.3), and Bundler cannot continue. Make sure that gem install minitest -v '5.10.3' succeeds before bundling.

In Gemfile: rails was resolved to 5.0.6, which depends on actioncable was resolved to 5.0.6, which depends on actionpack was resolved to 5.0.6, which depends on actionview was resolved to 5.0.6, which depends on rails-dom-testing was resolved to 2.0.3, which depends on activesupport was resolved to 5.0.6, which depends on minitest

if I would install the specific gem it would only ask for more...