본문 바로가기

프로그램 경험/Ruby/Rails

[Rails] rails new blog 시 오류

이미 내 자리엔 rails와 ruby가 설치 되어 있다.

레드마인 인스톨러가 설치시 함께 설치 했기 때문이다.


레일즈 공부를 처음 부터 해보려고 아래 사이트를 찾았다.


http://rubykr.github.com/rails_guides/getting_started.html


그리고 시작을 위해 터미널을 열고 아래 명령어를 실행 했다.


$ rails new blog


바로 오류...


C:/BitNami Redmine Stack/ruby/lib/ruby/gems/1.8/gems/railties-3.2.6/lib/rails/generators/app_base.rb:254:in ``': 

Invalid argument - ""C:/BitNami Redmine Stack/ruby/bin/ruby.exe"" -rubygems "C:/BitNami Redmine Stack/ruby/lib/ruby/gems/1.8/gems/bundler-1.0.21/bin/bundle" install (Errno::EINVAL)


app_base.rb 파일을 열어서 보면 아래와 같은 부분이 보인다.
레드마인의 경로에 이미 쌍따옴표가 들어 있어서 오류가 난것이다.

print `"#{Gem.ruby}" -rubygems "#{Gem.bin_path('bundler', 'bundle')}" #{command}`
=> print `#{Gem.ruby} -rubygems "#{Gem.bin_path('bundler', 'bundle')}" #{command}`

수정하고 다시 하면 이번에 또 다른 오류...

Installing json (1.7.6)
Gem::InstallError: The 'json' native gem requires installed build tools.

Please update your PATH to include build tools or download the DevKit
from 'http://rubyinstaller.org/downloads' and follow the instructions
at 'http://github.com/oneclick/rubyinstaller/wiki/Development-Kit'
An error occured while installing json (1.7.6), and Bundler cannot continue.
Make sure that `gem install json -v '1.7.6'` succeeds before bundling.

JSON 설치시 문제가 발생했다.
우선 하라는 대로 http://rubyinstaller.org/downloads/ 사이트에 가서 Development-Kit 를 다운받는다.
다운 받고 폴더 하나 만들고 압축풀고 해당 경로를 환경변수 경로 잡아주고 CMD창 다시 닫고 열고 해도 오류...

이짓 저짓 하는 가운데 새로운 오류 등장.

"C:/BitNami Redmine Stack/ruby/bin/ruby.exe" extconf.rb
creating Makefile

make
Makefile:130: warning: overriding commands for target `C:/BitNami'
Makefile:124: warning: ignoring old commands for target `C:/BitNami'
Makefile:130: warning: overriding commands for target `Redmine'
Makefile:124: warning: ignoring old commands for target `Redmine'
gcc -I. -I"/C/BitNami Redmine Stack/ruby/lib/ruby/1.8/i386-mingw32" -I"/C/BitNami Redmine Stack/ruby/lib/ruby/1.8/i386-mingw32" -I. -DJSON_GENERATOR    -g -O3 -DFD_SETSIZE=256   -Wall -O0 -ggdb  -c generator.c
m.AllocationBase 0x0, m.BaseAddress 0x60E90000, m.RegionSize 0x170000, m.State 0x10000
C:\railsdevkit\bin\rm.exe: *** Couldn't reserve space for cygwin's heap (0x60E90000 <0x1A20000>) in child, Win32 error 0
make: [generator.so] Error 1 (ignored)
gcc -shared -s -o generator.so generator.o -L. -LC:/BitNami Redmine Stack/ruby/lib -L.  -Wl,--enable-auto-image-base,--enable-auto-import,--export-all   -lmsvcrt-ruby18  -lshell32 -lws2_32  
gcc.exe: Redmine: No such file or directory
gcc.exe: Stack/ruby/lib: No such file or directory
make: *** [generator.so] Error 1

이건 해당 경로(C:\railsdevkit\bin)에 msys-1.0.dll 파일을 삭제 하고 새로운 파일로 변경하니 해결 되었다.

msys-1.0.zip



하지만 JSON은 여전히 오류나고 make 파일 수정하고 지랄 다 해봤지만 안된다.

문제의 원인은 폴더명에 띄어쓰기가 들어 있는것이다. (C:/BitNami Redmine Stack)

결국 레드마인 서비스 다 멈추고 폴더명을 바꾼뒤 울트라에디트로 모든 설정파일들의 경로도 변경된 경로로 바꾸었다.
그리고 서비스 삭제후 다시 설치

C:\BitNamiRedmine\serviceinstall.bat                   //서비스 삭제
C:\BitNamiRedmine\serviceinstall.bat INSTALL      //서비스 설치

그리고 devkit 설치한 폴더로 가서 루비 경로를 설정한다.

C:\railsdevkit> ruby dk.rb init  

이제 해당 폴더에 config.yml 파일이 생긴다.
파일을 수정해서 아래 한줄 넣어준다.

- C:/BitNamiRedmine/ruby

그리고 인스톨

C:\railsdevkit> ruby dk.rb review
C:\railsdevkit> ruby dk.rb install

이제 다시 rails new blog 하면 별탈 없이 생길것이다.
개고생 했다...