This project is archived and is in readonly mode.

#3861 ✓resolved
Nick Clarke

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

Reported by Nick Clarke | February 5th, 2010 @ 12:56 PM | in 3.0.2

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>'

Comments and changes to this ticket

  • Torsten Maul

    Torsten Maul February 5th, 2010 @ 01:22 PM

    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.

  • Fredrik Henne

    Fredrik Henne February 8th, 2010 @ 09:31 PM

    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.

  • Matt Hulse

    Matt Hulse February 8th, 2010 @ 09:38 PM

    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'?

  • Fredrik Henne

    Fredrik Henne February 8th, 2010 @ 11:29 PM

    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.

  • Nick Clarke

    Nick Clarke February 8th, 2010 @ 11:50 PM

    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.

  • E. Rider

    E. Rider February 9th, 2010 @ 11:33 AM

    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)

  • Matt Hulse

    Matt Hulse March 7th, 2010 @ 06:17 PM

    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?

  • José Valim

    José Valim March 26th, 2010 @ 10:47 PM

    • State changed from “new” to “resolved”
    • Assigned user set to “Xavier Noria”
    • Milestone cleared.

    Fixed on master.

  • Ryan Bigg

    Ryan Bigg October 9th, 2010 @ 09:54 PM

    • Tag cleared.

    Automatic cleanup of spam.

  • Jeremy Kemper

    Jeremy Kemper October 15th, 2010 @ 11:01 PM

    • Milestone set to 3.0.2

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »

<h2 style="font-size: 14px">Tickets have moved to Github</h2>

The new ticket tracker is available at <a href="https://github.com/rails/rails/issues">https://github.com/rails/rails/issues</a>

Referenced by

Pages