Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Ruby

Rails server impossible to start (on port 3000) [Resolved]

Hello, I want to discover Ruby on Rails so I started by the Ruby environment installation and Rails is installed, even if I couldn't manage to install rbenv and rvm.

I created a project named treerails and when I type rails server in the bin/ directory, the server doesn't start on localhost:3000. Or I have all these following lines :

[lukas90@Lukas90 bin]$ rails server
Warning: You're using Rubygems 1.8.25 with Spring. Upgrade to at least Rubygems 2.1.0 and run `gem pristine --all` for better startup performance.
bin/rails:6: warning: already initialized constant APP_PATH
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.

Now, I already have the last version of Ruby installed (2.1.2p95) thanks to the binary source install method and the last version of Rubygems installed with the command gem update --system, and the last version of Rails (4.1.4), but it doesn't work anymore.

Otherwise, I also tried the command gem pristine --all, but I always have the following results and an error due to a bigdecimal gem, which I already installed :

sudo gem pristine --all
Restoring gems to pristine condition...
Restored abstract-1.0.0
Restored actionmailer-4.1.4
Restored actionmailer-3.0.11
Restored actionpack-4.1.4
Restored actionpack-3.0.11
Restored actionview-4.1.4
Restored activemodel-4.1.4
Restored activemodel-3.0.11
Restored activerecord-4.1.4
Restored activerecord-3.0.11
Restored activeresource-3.0.11
Restored activesupport-4.1.4
Restored activesupport-3.0.11
Restored arel-5.0.1.20140414130214
Restored arel-2.0.9
Building native extensions.  This could take a while...
Restored bigdecimal-1.2.5
Cached gem for bigdecimal-1.1.0 not found, attempting to fetch...
ERROR:  While executing gem ... (Gem::InstallError)
    invalid gem: No such file or directory - /usr/share/gems/cache/bigdecimal-1.1.0.gem

4 Answers

Maciej Czuchnowski
Maciej Czuchnowski
36,441 Points

Did you go into the project folder before running the server? cd treerails

No, but now I am in this folder, I have these errors :

[lukas90@Lukas90 treerails]$ bin/rails server 
/usr/local/lib/ruby/2.1.0/rubygems/core_ext/kernel_require.rb:55:in `require': cannot load such file -- bundler/setup (LoadError)
    from /usr/local/lib/ruby/2.1.0/rubygems/core_ext/kernel_require.rb:55:in `require'
    from /home/lukas90/Treehouse/Ruby/Rails/treerails/config/boot.rb:4:in `<top (required)>'
    from bin/rails:7:in `require_relative'
    from bin/rails:7:in `<main>'

So, what's going on ?

Maciej Czuchnowski
Maciej Czuchnowski
36,441 Points

I have no idea :) try rails server without the bin/ prefix. Also, maybe this will point you somwehere: https://github.com/tpope/vim-rails/issues/288

Maciej Czuchnowski
Maciej Czuchnowski
36,441 Points

Last answer here seems to point to a solution, but you will need to do some reinstalling: https://teamtreehouse.com/forum/errors-for-testing-ruby-install

OK, so I retourned in the bin/ folder and I type the command rails server, but nothing changes.

I also tried the variant bundle exec rails server, and I have a new message now :

[lukas90@Lukas90 bin]$ bundle exec rails server
bin/rails:6: warning: already initialized constant APP_PATH

Is this linked with an environment variable, the .bashrc file or something like that ?

Maciej Czuchnowski
Maciej Czuchnowski
36,441 Points

You can only run rails server within the folder that has a proper Rails application in it, running it anywhere else won't work. If you're using Mac, this is all I can tell you, since I never used a Mac (and I'm never going to use one voluntarily). Try the links I gave you in the comments above.

OK, I tried the previous links, but I don't understand so many things or the solutions don't work for me. I think I'll give up Ruby on Rails on Linux, unless I use a Mac on a VM machine with a mensual pricing.

I am sick of staying hours and hours for searching and testing solutions that doesn't work. Before, it was Laravel. Now, it's Ruby on Rails. I give up for now and I continue with other technologies like CSS, jQuery or PHP.

Edit : I installed some missing gems and when I type sudo bin/rails server ou sudo bin/bundle exec rails server, I have the following lines of errors :

Warning: Running `gem pristine --all` to regenerate your installed gemspecs (and deleting then reinstalling your bundle if you use bundle --path) will improve the startup performance of Spring.
/home/lukas90/Treehouse/Ruby/Rails/treerails/path/ruby/1.9.1/gems/execjs-2.2.1/lib/execjs/runtimes.rb:51:in `autodetect': Could not find a JavaScript runtime. See https://github.com/sstephenson/execjs for a list of available runtimes. (ExecJS::RuntimeUnavailable)
    from /home/lukas90/Treehouse/Ruby/Rails/treerails/path/ruby/1.9.1/gems/execjs-2.2.1/lib/execjs.rb:5:in `<module:ExecJS>'
    from /home/lukas90/Treehouse/Ruby/Rails/treerails/path/ruby/1.9.1/gems/execjs-2.2.1/lib/execjs.rb:4:in `<top (required)>'
    from /home/lukas90/Treehouse/Ruby/Rails/treerails/path/ruby/1.9.1/gems/uglifier-2.5.3/lib/uglifier.rb:3:in `require'
    from /home/lukas90/Treehouse/Ruby/Rails/treerails/path/ruby/1.9.1/gems/uglifier-2.5.3/lib/uglifier.rb:3:in `<top (required)>'
    from /usr/local/share/gems/gems/bundler-1.6.5/lib/bundler/runtime.rb:76:in `require'
    from /usr/local/share/gems/gems/bundler-1.6.5/lib/bundler/runtime.rb:76:in `block (2 levels) in require'
    from /usr/local/share/gems/gems/bundler-1.6.5/lib/bundler/runtime.rb:72:in `each'
    from /usr/local/share/gems/gems/bundler-1.6.5/lib/bundler/runtime.rb:72:in `block in require'
    from /usr/local/share/gems/gems/bundler-1.6.5/lib/bundler/runtime.rb:61:in `each'
    from /usr/local/share/gems/gems/bundler-1.6.5/lib/bundler/runtime.rb:61:in `require'
    from /usr/local/share/gems/gems/bundler-1.6.5/lib/bundler.rb:132:in `require'
    from /home/lukas90/Treehouse/Ruby/Rails/treerails/config/application.rb:7:in `<top (required)>'
    from /home/lukas90/Treehouse/Ruby/Rails/treerails/path/ruby/1.9.1/gems/railties-4.1.4/lib/rails/commands/commands_tasks.rb:79:in `require'
    from /home/lukas90/Treehouse/Ruby/Rails/treerails/path/ruby/1.9.1/gems/railties-4.1.4/lib/rails/commands/commands_tasks.rb:79:in `block in server'
    from /home/lukas90/Treehouse/Ruby/Rails/treerails/path/ruby/1.9.1/gems/railties-4.1.4/lib/rails/commands/commands_tasks.rb:76:in `tap'
    from /home/lukas90/Treehouse/Ruby/Rails/treerails/path/ruby/1.9.1/gems/railties-4.1.4/lib/rails/commands/commands_tasks.rb:76:in `server'
    from /home/lukas90/Treehouse/Ruby/Rails/treerails/path/ruby/1.9.1/gems/railties-4.1.4/lib/rails/commands/commands_tasks.rb:40:in `run_command!'
    from /home/lukas90/Treehouse/Ruby/Rails/treerails/path/ruby/1.9.1/gems/railties-4.1.4/lib/rails/commands.rb:17:in `<top (required)>'
    from /home/lukas90/Treehouse/Ruby/Rails/treerails/bin/rails:8:in `require'
    from /home/lukas90/Treehouse/Ruby/Rails/treerails/bin/rails:8:in `<top (required)>'
    from /home/lukas90/Treehouse/Ruby/Rails/treerails/path/ruby/1.9.1/gems/spring-1.1.3/lib/spring/client/rails.rb:27:in `load'
    from /home/lukas90/Treehouse/Ruby/Rails/treerails/path/ruby/1.9.1/gems/spring-1.1.3/lib/spring/client/rails.rb:27:in `call'
    from /home/lukas90/Treehouse/Ruby/Rails/treerails/path/ruby/1.9.1/gems/spring-1.1.3/lib/spring/client/command.rb:7:in `call'
    from /home/lukas90/Treehouse/Ruby/Rails/treerails/path/ruby/1.9.1/gems/spring-1.1.3/lib/spring/client.rb:26:in `run'
    from /home/lukas90/Treehouse/Ruby/Rails/treerails/path/ruby/1.9.1/gems/spring-1.1.3/bin/spring:48:in `<top (required)>'
    from /home/lukas90/Treehouse/Ruby/Rails/treerails/path/ruby/1.9.1/gems/spring-1.1.3/lib/spring/binstub.rb:11:in `load'
    from /home/lukas90/Treehouse/Ruby/Rails/treerails/path/ruby/1.9.1/gems/spring-1.1.3/lib/spring/binstub.rb:11:in `<top (required)>'
    from /usr/local/share/ruby/site_ruby/rubygems/core_ext/kernel_require.rb:54:in `require'
    from /usr/local/share/ruby/site_ruby/rubygems/core_ext/kernel_require.rb:54:in `require'
    from /home/lukas90/Treehouse/Ruby/Rails/treerails/bin/spring:16:in `<top (required)>'
    from bin/rails:3:in `load'
    from bin/rails:3:in `<main>'

And without sudo, I have this :

[lukas90@Lukas90 treerails]$ bin/rails server
/usr/local/lib/ruby/2.1.0/rubygems/core_ext/kernel_require.rb:55:in `require': cannot load such file -- bundler/setup (LoadError)
    from /usr/local/lib/ruby/2.1.0/rubygems/core_ext/kernel_require.rb:55:in `require'
    from /home/lukas90/Treehouse/Ruby/Rails/treerails/config/boot.rb:4:in `<top (required)>'
    from bin/rails:7:in `require_relative'
    from bin/rails:7:in `<main>'