Where did “Command Prompt with Ruby on Rails” come

2019-07-17 14:08发布

So we understand, I use Windows 7.

I've been fighting my way through ruby.railstutorial.org/ruby-on-rails-tutorial-book, but I seemed to have split my command prompts. Originally, I installed Rails based on the instructions from here: http://railsinstaller.org/windows (this was where guides.rubyonrails sent here). I didn't notice it until much later, but it seems I created a Command Prompt called "Command Prompt with Ruby on Rails" after following the instructions there.

Now, throughout the rest of RonR tutorial at guides.rubyonrails, I have been using my REGULAR Command Prompt. Meanwhile, I have been running into a lot of strange problems, such as:

  • gemfiles/gems not being found even after I explicitly install and/or add them
  • EACCES errors when I try to do "Bundle Install" from the location of my app (or any location for that matter)

As a final note, "Command Prompt with Ruby on Rails" always seems to launch from C:\Sites> ( this was the location of my original "demo app" when I installed Rails from railsinstaller.org/windows). However, even if I try deleting \Sites, if I reopen the "Command Prompt with Ruby on Rails", it magically recreates \Sites.

2条回答
一纸荒年 Trace。
2楼-- · 2019-07-17 14:41

The RoR command prompt is just a short cut to cmd.exe with some modifications. You can see this if you right-click and select properties on the RoR command prompt.

If you want to change the starting location, go to the following location (may be different depending on where you directed the RailsInstaller to set up Ruby and Rails):

C:\RailsInstaller\Ruby1.9.3\setup_environment.bat

And add the following line to the end (insert your own path).

CD *PATHTOYOURFOLDER*

However, this is a quick fix and will still create the Sites folder. You can further modify the batch file to avoid creating the unnecessary directory.

查看更多
混吃等死
3楼-- · 2019-07-17 14:47

The RoR command prompt is just a shortcut to CMD.exe with the initial working directory set to c:\sites, and the %PATH% setup to include your gems and ruby (I guess it could be a custom shortcut, or a batch file to set things up, or an EXE that does the equivalent). It might also be an administrator prompt that has write access to the Ruby install path. It is probably re-creating your directory as it writes some file, perhaps a log, cache, or settings related to 'last time this was run'.

If it is a shortcut or batch file, you should be able to edit it to change the starting location. The errors you are getting are probably due to not having the right %PATH% and permissions.

查看更多
登录 后发表回答