2012-11-07 37 views
12

我做了一個批處理文件試圖安裝耙在Windows /長鰭環境:批處理文件後不運行下一個命令「寶石安裝」

@echo off 

echo Setting up rake environment for building 

echo Installing Bundler 
gem install bundler 

echo Bundle Installing gems 
bundle install 

當我運行這個批處理文件(或者雙擊或在cmd窗口中運行),只執行第一個gem命令。 '捆綁安裝'永遠不會被調用。下面是輸出:

C:\>InstallGems.bat 
Setting up rake environment for building 
Installing Bundler 
Successfully installed bundler-1.2.1 
1 gem installed 
Installing ri documentation for bundler-1.2.1... 
Installing RDoc documentation for bundler-1.2.1... 

C:\> 

我加入了「暫停」後的第一次「創業板安裝」命令,它似乎是「暫停」時也從未執行。

有什麼想法?

+0

Gem本身可能是一個批處理文件,或者腳本由於錯誤而不知何故中止並且不會告訴您有關錯誤。 –

回答

19

啊,我想通了:在每個命令前加上'call'。

@echo off 

echo Setting up rake environment for building 

echo Installing Bundler 
call gem install bundler 

echo Bundle Installing gems 
call bundle install 
+4

似乎gem是一個批處理文件本身。由於以前的操作方式,爲了向後兼容性,這種行爲是通過設計:http://stackoverflow.com/questions/11638705/why-does-calling-a-nested-batch-file-without-prepending-call-到該行退出 – SeanC

相關問題