Lighthouse has a new layout. Prefer the old one? Return to the old layout, and switch back any time from the link at the top of each page.

This project is archived and is in readonly mode.

"script/* replaced by script/rails" not working

#3861

Hi

I just installed the new beta version of rails 3 and ran into a error with the new script/rails commands.

I'm running:
Windows 7 64bit
ruby 1.9.1p243 (2009-07-16 revision 24175) [i386-mingw32] (One Click installer)

Below are the steps I did:

  C:\Users\username\Documents>rails v3app
  create
  create  README
  create  .gitignore
  create  Rakefile
  create  config.ru
  create  Gemfile
  create  app
  create  app/controllers/application_controller.rb
  create  app/helpers/application_helper.rb
  create  app/models
  create  app/views/layouts
  create  config
  create  config/routes.rb
  create  config/application.rb
  create  config/environment.rb
  create  config/environments
  create  config/environments/development.rb
  create  config/environments/production.rb
  create  config/environments/test.rb
  create  config/initializers
  create  config/initializers/backtrace_silencers.rb
  create  config/initializers/cookie_verification_secret.rb
  create  config/initializers/inflections.rb
  create  config/initializers/mime_types.rb
  create  config/initializers/session_store.rb
  create  config/locales
  create  config/locales/en.yml
  create  config/boot.rb
  create  config/database.yml
  create  db
  create  db/seeds.rb
  create  doc
  create  doc/README_FOR_APP
  create  lib
  create  lib/tasks
  create  lib/tasks/.gitkeep
  create  log
  create  log/server.log
  create  log/production.log
  create  log/development.log
  create  log/test.log
  create  public
  create  public/404.html
  create  public/422.html
  create  public/500.html
  create  public/favicon.ico
  create  public/index.html
  create  public/robots.txt
  create  public/images
  create  public/images/rails.png
  create  public/stylesheets
  create  public/stylesheets/.gitkeep
  create  public/javascripts
  create  public/javascripts/application.js
  create  public/javascripts/controls.js
  create  public/javascripts/dragdrop.js
  create  public/javascripts/effects.js
  create  public/javascripts/prototype.js
  create  public/javascripts/rails.js
  create  script
  create  script/rails
  create  test
  create  test/performance/browsing_test.rb
  create  test/test_helper.rb
  create  test/fixtures
  create  test/functional
  create  test/integration
  create  test/unit
  create  tmp
  create  tmp/sessions
  create  tmp/sockets
  create  tmp/cache
  create  tmp/pids
  create  vendor/plugins
  create  vendor/plugins/.gitkeep

  C:\Users\username\Documents>cd v3app

Now when I run any of the following commands I see the same error:

  C:\Users\username\Documents\v3app>rails --help
  C:\Users\username\Documents\v3app>rails console
  C:\Users\username\Documents\v3app>rails g scaffold post title:string

all generate the following error:

  C:/Ruby19/lib/ruby/gems/1.9.1/gems/railties-3.0.0.beta/bin/rails:2: command not
  found: C:/Users/username/Documents/v3app/script/rails
  C:/Ruby19/lib/ruby/gems/1.9.1/gems/railties-3.0.0.beta/bin/rails:2:in `exec': No
   such file or directory - C:/Users/username/Documents/v3app/script
  /rails (Errno::ENOENT)
  from C:/Ruby19/lib/ruby/gems/1.9.1/gems/railties-3.0.0.beta/bin/rails:2:
  in `<top (required)>'
    from C:/Ruby19/bin/rails:19:in `load'
    from C:/Ruby19/bin/rails:19:in `<main>'

Reported by Nick Clarke · February 5th, 2010 @ 12:56 PM

State: resolved
Milestone: 3.0.2
Assigned to: Xavier Noria Xavier Noria
Importance: Low

Activity

  1. Torsten Maul
    Torsten Maul

    I can reproduce this problem on my Windows XP box with Rails 3.0.0.beta, but instead of getting an Errno::ENOENT, I am getting an Errn
    o::ENOEXEC. Nonetheless there seems to be an issue with the exec() call in file <MY_RUBY_INSTALL>/lib/ruby/gems/1.8/gems/railties-3.0.0.beta/bin/rails on line 2.

    I was able to fix this by changing the file on line 2 into the following: exec('ruby', Dir.getwd + '/script/rails', *ARGV)

    Hope this helps.

    February 5th, 2010 @ 01:22 PM

  2. Fredrik Henne
    Fredrik Henne

    Torsten Maul's fix works under Ruby 1.8.7, but not using 1.9.1.

    Windows-users forced to stay in 1.8.7 then I guess.

    February 8th, 2010 @ 09:31 PM

  3. Matt Hulse
    Matt Hulse

    That fix worked for me on WinXP Pro using 1.9.1 RC2 from RubyInstaller.org. For his fix to work, ruby has to be in your path. Instead of 'rails server' from the root of your new rails app, what do you get if you type 'ruby script\rails server'?

    February 8th, 2010 @ 09:38 PM

  4. Fredrik Henne
    Fredrik Henne

    My bad, the fix indeed works on Windows with Ruby 1.9.1. Though you get problems with invalid .gemspecs (related to Bundler). Mentioned and fixed in http://github.com/carlhuda/bundler/issues/issue/24#issue/24/comment.... Next version of Bundler should fix that.

    February 8th, 2010 @ 11:29 PM

  5. Nick Clarke
    Nick Clarke

    Thanks Torsten for the fix.

    It seemed to work but I also now get the same issue that Fredrik mentions inc the massive error output.

    I'll keep an eye on the Bundler update and will retest once it is released.

    February 8th, 2010 @ 11:50 PM

  6. E. Rider
    E. Rider

    The fix from Torsten works also for me but with some addition.
    In my case, 'ruby' is not the name of my executable. It is ruby18.

    I've replaced the second line of the file:
    exec(Dir.getwd + '/script/rails', *ARGV)

    with the following which is safer regarding the name of the ruby executable name:
    require 'rbconfig'
    ruby_exe = Config::CONFIG["ruby_install_name"]
    exec(ruby_exe, Dir.getwd + '/script/rails', *ARGV)

    February 9th, 2010 @ 11:33 AM

  7. Matt Hulse
    Matt Hulse

    Another solution is to replace:

    2: exec(Dir.getwd + '/script/rails', *ARGV)

    with

    2: load(Dir.getwd + '/script/rails')

    This solution was posted in the comments of the official beta release announcement by @Trys. At first glance, I didn't think it would work for cases like:

    rails generate scaffold log entry:string

    because it doesn't explicitly pass the arguments along but it has worked perfectly in every case that I've tried so far.

    Using load is definitely a much simpler solution but I'm not sure if it is a better solution than others that have been proposed. Thoughts?

    March 7th, 2010 @ 06:17 PM

  8. José Valim
    José Valim
    • State changed from new to resolved
    • Assigned user set to Xavier Noria
    • Milestone cleared.

    Fixed on master.

    March 26th, 2010 @ 10:47 PM

  9. Ryan Bigg
    Ryan Bigg
    • Tag cleared.

    Automatic cleanup of spam.

    October 9th, 2010 @ 09:54 PM

  10. Jeremy Kemper