Rails - The system cannot find the path specified

前端 未结 10 1890
天命终不由人
天命终不由人 2020-12-07 11:21

I have installed Rails and Ruby on Windows with railsinstaller. The problem is, when I run the rails command, it gives me: \"The system cannot find the path specified.\"

相关标签:
10条回答
  • 2020-12-07 11:54

    The solution is specified on github issues of railsinstaller - https://github.com/railsinstaller/railsinstaller-windows/issues/73

    0 讨论(0)
  • 2020-12-07 11:55

    I opened all the .bat files under C:\RailsInstaller\Ruby2.2.0\bin in Sublime Text, and replaced with Ctrl+Shift+F,

    this
    @"C:\Users\emachnic\GitRepos\railsinstaller-windows\stage\Ruby2.2.0\bin\ruby.exe"
    with this
    @"%~dp0ruby.exe"
    across all files that had a match.

    Took only a couple of seconds. This might help someone who stumbles across it after me and is daunted by the idea of performing a find and replace over multiple files.

    0 讨论(0)
  • 2020-12-07 11:59

    I came across this issue a couple of days ago. It seems like all of a sudden after you run Rails many times on Windows, playing with the cmd command prompt, changing the command background and text colors or opening more than one command prompt window at the same time, and then you try to run the command 'rails server' 'rails new App' or 'bundle install' you get the message "The system cannot find the path specified"

    I solved that problem by running the command: 'gem install _____' (fill out that line with: 'bundle', 'bundler' and 'byebug'), which are the names of three .bat files (run that command with each .bat file name ONE AT A TIME). Once you have done that, test it! Try to create a new app, bundle install and rails server. It worked for me.

    0 讨论(0)
  • 2020-12-07 12:02

    I believe the fix for the above problem is very simple.

    The problem is happening because in the installation directory the batch that you have is taking default path. For e.g., let say that you are running following command: bundle install Now in order to execute this command your bundle batch file should be configured correctly. By default the batch file will have somewhat like below structure:

    @ECHO OFF
    IF NOT "%~f0" == "~f0" GOTO :WinNT
    @"C:\Users\emachnic\GitRepos\railsinstaller-windows\stage\Ruby2.3.0\bin\ruby.exe" 
    "C:/Users/emachnic/GitRepos/railsinstaller-windows/stage/Ruby2.3.0/bin/bundle" %1 %2 %3 %4 %5 %6 %7 %8 %9
    GOTO :EOF
    :WinNT
    @"C:\Users\emachnic\GitRepos\railsinstaller-windows\stage\Ruby2.3.0\bin\ruby.exe" "%~dpn0" %
    

    For me rails is installed in C drive : C:\RailsInstaller\Ruby2.3.0\bin hence the above bundle file should be configured something like below:

    @ECHO OFF
    IF NOT "%~f0" == "~f0" GOTO :WinNT
    @"C:/RailsInstaller/Ruby2.3.0/bin/ruby.exe" 
    "C:/RailsInstaller/Ruby2.3.0/bin/bundle" %1 %2 %3 %4 %5 %6 %7 %8 %9
    GOTO :EOF
    :WinNT
    @"C:/RailsInstaller/Ruby2.3.0/bin/ruby.exe" "%~dpn0" %
    

    This will solve the above problem.

    The above solution should be applied whereever we face the problem running command.

    0 讨论(0)
提交回复
热议问题