ติดตั้งรางบน Mac OS X


6

ฉันพยายามติดตั้ง Rails บน Mac OS X ฉันได้ติดตั้งแล้ว ruby.

$ ruby -v
ruby 2.0.0p247 (2013-06-27 revision 41674) [x86_64-darwin11.4.2]

ฉันจะตรวจสอบว่าติดตั้ง Rails:

$ rails -v 
Rails is not currently installed on this system. To get the latest version, simply type:

    $ sudo gem install rails

You can then rerun your "rails" command.

จากนั้นฉันก็วิ่ง:

$ sudo gem install rails
Password:
Successfully installed rails-4.0.0
Parsing documentation for rails-4.0.0
unable to convert "\x89" from ASCII-8BIT to UTF-8 for guides/assets/images/belongs_to.png, skipping
unable to convert "\xF4" from ASCII-8BIT to UTF-8 for guides/assets/images/book_icon.gif, skipping
unable to convert "\x91" from ASCII-8BIT to UTF-8 for guides/assets/images/bullet.gif, skipping
unable to convert "\xF5" from ASCII-8BIT to UTF-8 for guides/assets/images/chapters_icon.gif, skipping
unable to convert "\xF5" from ASCII-8BIT to UTF-8 for guides/assets/images/check_bullet.gif, skipping
unable to convert "\xF4" from ASCII-8BIT to UTF-8 for guides/assets/images/credits_pic_blank.gif, skipping
unable to convert "\x89" from ASCII-8BIT to UTF-8 for guides/assets/images/csrf.png, skipping
unable to convert "\x89" from ASCII-8BIT to UTF-8 for guides/assets/images/edge_badge.png, skipping
unable to convert "\x9E" from ASCII-8BIT to UTF-8 for guides/assets/images/favicon.ico, skipping
unable to convert "\x80" from ASCII-8BIT to UTF-8 for guides/assets/images/feature_tile.gif, skipping
unable to convert "\x80" from ASCII-8BIT to UTF-8 for guides/assets/images/footer_tile.gif, skipping
unable to convert "\x89" from ASCII-8BIT to UTF-8 for guides/assets/images/fxn.png, skipping
unable to convert "\x89" from ASCII-8BIT to UTF-8 for guides/assets/images/getting_started/challenge.png, skipping
unable to convert "\x89" from ASCII-8BIT to UTF-8 for guides/assets/images/getting_started/confirm_dialog.png, skipping
unable to convert "\x89" from ASCII-8BIT to UTF-8 for guides/assets/images/getting_started/forbidden_attributes_for_new_post.png, skipping
unable to convert "\x89" from ASCII-8BIT to UTF-8 for guides/assets/images/getting_started/form_with_errors.png, skipping
unable to convert "\x89" from ASCII-8BIT to UTF-8 for guides/assets/images/getting_started/index_action_with_edit_link.png, skipping
unable to convert "\x89" from ASCII-8BIT to UTF-8 for guides/assets/images/getting_started/new_post.png, skipping
unable to convert "\x89" from ASCII-8BIT to UTF-8 for guides/assets/images/getting_started/post_with_comments.png, skipping
unable to convert "\x89" from ASCII-8BIT to UTF-8 for guides/assets/images/getting_started/rails_welcome.png, skipping
unable to convert "\x89" from ASCII-8BIT to UTF-8 for guides/assets/images/getting_started/routing_error_no_controller.png, skipping
unable to convert "\x89" from ASCII-8BIT to UTF-8 for guides/assets/images/getting_started/routing_error_no_route_matches.png, skipping
unable to convert "\x89" from ASCII-8BIT to UTF-8 for guides/assets/images/getting_started/show_action_for_posts.png, skipping
unable to convert "\x89" from ASCII-8BIT to UTF-8 for guides/assets/images/getting_started/template_is_missing_posts_new.png, skipping
unable to convert "\x89" from ASCII-8BIT to UTF-8 for guides/assets/images/getting_started/undefined_method_post_path.png, skipping
unable to convert "\x89" from ASCII-8BIT to UTF-8 for guides/assets/images/getting_started/unknown_action_create_for_posts.png, skipping
unable to convert "\x89" from ASCII-8BIT to UTF-8 for guides/assets/images/getting_started/unknown_action_new_for_posts.png, skipping
unable to convert "\xF0" from ASCII-8BIT to UTF-8 for guides/assets/images/grey_bullet.gif, skipping
unable to convert "\x89" from ASCII-8BIT to UTF-8 for guides/assets/images/habtm.png, skipping
unable to convert "\x89" from ASCII-8BIT to UTF-8 for guides/assets/images/has_many.png, skipping
unable to convert "\x89" from ASCII-8BIT to UTF-8 for guides/assets/images/has_many_through.png, skipping
unable to convert "\x89" from ASCII-8BIT to UTF-8 for guides/assets/images/has_one.png, skipping
unable to convert "\x89" from ASCII-8BIT to UTF-8 for guides/assets/images/has_one_through.png, skipping
unable to convert "\x89" from ASCII-8BIT to UTF-8 for guides/assets/images/header_backdrop.png, skipping
unable to convert "\x80" from ASCII-8BIT to UTF-8 for guides/assets/images/header_tile.gif, skipping
unable to convert "\x89" from ASCII-8BIT to UTF-8 for guides/assets/images/i18n/demo_html_safe.png, skipping
unable to convert "\x89" from ASCII-8BIT to UTF-8 for guides/assets/images/i18n/demo_localized_pirate.png, skipping
unable to convert "\x89" from ASCII-8BIT to UTF-8 for guides/assets/images/i18n/demo_translated_en.png, skipping
unable to convert "\x89" from ASCII-8BIT to UTF-8 for guides/assets/images/i18n/demo_translated_pirate.png, skipping
unable to convert "\x89" from ASCII-8BIT to UTF-8 for guides/assets/images/i18n/demo_translation_missing.png, skipping
unable to convert "\x89" from ASCII-8BIT to UTF-8 for guides/assets/images/i18n/demo_untranslated.png, skipping
unable to convert "\x89" from ASCII-8BIT to UTF-8 for guides/assets/images/icons/callouts/1.png, skipping
unable to convert "\x89" from ASCII-8BIT to UTF-8 for guides/assets/images/icons/callouts/10.png, skipping
unable to convert "\x89" from ASCII-8BIT to UTF-8 for guides/assets/images/icons/callouts/11.png, skipping
unable to convert "\x89" from ASCII-8BIT to UTF-8 for guides/assets/images/icons/callouts/12.png, skipping
unable to convert "\x89" from ASCII-8BIT to UTF-8 for guides/assets/images/icons/callouts/13.png, skipping
unable to convert "\x89" from ASCII-8BIT to UTF-8 for guides/assets/images/icons/callouts/14.png, skipping
unable to convert "\x89" from ASCII-8BIT to UTF-8 for guides/assets/images/icons/callouts/15.png, skipping
unable to convert "\x89" from ASCII-8BIT to UTF-8 for guides/assets/images/icons/callouts/2.png, skipping
unable to convert "\x89" from ASCII-8BIT to UTF-8 for guides/assets/images/icons/callouts/3.png, skipping
unable to convert "\x89" from ASCII-8BIT to UTF-8 for guides/assets/images/icons/callouts/4.png, skipping
unable to convert "\x89" from ASCII-8BIT to UTF-8 for guides/assets/images/icons/callouts/5.png, skipping
unable to convert "\x89" from ASCII-8BIT to UTF-8 for guides/assets/images/icons/callouts/6.png, skipping
unable to convert "\x89" from ASCII-8BIT to UTF-8 for guides/assets/images/icons/callouts/7.png, skipping
unable to convert "\x89" from ASCII-8BIT to UTF-8 for guides/assets/images/icons/callouts/8.png, skipping
unable to convert "\x89" from ASCII-8BIT to UTF-8 for guides/assets/images/icons/callouts/9.png, skipping
unable to convert "\x89" from ASCII-8BIT to UTF-8 for guides/assets/images/icons/caution.png, skipping
unable to convert "\x89" from ASCII-8BIT to UTF-8 for guides/assets/images/icons/example.png, skipping
unable to convert "\x89" from ASCII-8BIT to UTF-8 for guides/assets/images/icons/home.png, skipping
unable to convert "\x89" from ASCII-8BIT to UTF-8 for guides/assets/images/icons/important.png, skipping
unable to convert "\x89" from ASCII-8BIT to UTF-8 for guides/assets/images/icons/next.png, skipping
unable to convert "\x89" from ASCII-8BIT to UTF-8 for guides/assets/images/icons/note.png, skipping
unable to convert "\x89" from ASCII-8BIT to UTF-8 for guides/assets/images/icons/prev.png, skipping
unable to convert "\x89" from ASCII-8BIT to UTF-8 for guides/assets/images/icons/tip.png, skipping
unable to convert "\x89" from ASCII-8BIT to UTF-8 for guides/assets/images/icons/up.png, skipping
unable to convert "\x89" from ASCII-8BIT to UTF-8 for guides/assets/images/icons/warning.png, skipping
unable to convert "\xFF" from ASCII-8BIT to UTF-8 for guides/assets/images/jaimeiniesta.jpg, skipping
unable to convert "\xF5" from ASCII-8BIT to UTF-8 for guides/assets/images/nav_arrow.gif, skipping
unable to convert "\xFF" from ASCII-8BIT to UTF-8 for guides/assets/images/oscardelben.jpg, skipping
unable to convert "\x89" from ASCII-8BIT to UTF-8 for guides/assets/images/polymorphic.png, skipping
unable to convert "\x89" from ASCII-8BIT to UTF-8 for guides/assets/images/radar.png, skipping
unable to convert "\x89" from ASCII-8BIT to UTF-8 for guides/assets/images/rails4_features.png, skipping
unable to convert "\xFF" from ASCII-8BIT to UTF-8 for guides/assets/images/rails_guides_kindle_cover.jpg, skipping
unable to convert "\xEC" from ASCII-8BIT to UTF-8 for guides/assets/images/rails_guides_logo.gif, skipping
unable to convert "\x8C" from ASCII-8BIT to UTF-8 for guides/assets/images/rails_logo_remix.gif, skipping
unable to convert "\x89" from ASCII-8BIT to UTF-8 for guides/assets/images/session_fixation.png, skipping
unable to convert "\x80" from ASCII-8BIT to UTF-8 for guides/assets/images/tab_grey.gif, skipping
unable to convert "\x80" from ASCII-8BIT to UTF-8 for guides/assets/images/tab_info.gif, skipping
unable to convert "\x80" from ASCII-8BIT to UTF-8 for guides/assets/images/tab_note.gif, skipping
unable to convert "\x80" from ASCII-8BIT to UTF-8 for guides/assets/images/tab_red.gif, skipping
unable to convert "\x80" from ASCII-8BIT to UTF-8 for guides/assets/images/tab_yellow.gif, skipping
unable to convert "\x89" from ASCII-8BIT to UTF-8 for guides/assets/images/tab_yellow.png, skipping
unable to convert "\xFF" from ASCII-8BIT to UTF-8 for guides/assets/images/vijaydev.jpg, skipping
1 gem installed

จากนั้นฉันก็จะวิ่งอีกครั้ง rails -v:

$ rails -v 
Rails is not currently installed on this system. To get the latest version, simply type:

    $ sudo gem install rails

You can then rerun your "rails" command.

ผลลัพธ์เดียวกัน คำถาม: ฉันพลาดอะไร?

ข้อมูลเพิ่มเติมของ rvm:

$ rvm -v

rvm 1.21.10 (stable) by Wayne E. Seguin <wayneeseguin@gmail.com>, Michal Papis <mpapis@gmail.com> [https://rvm.io/]

หมายเหตุ: Mac OS X ของฉันคือ 10.7.5 และบัญชีของฉันมีสิทธิ์ผู้ดูแล ไดเรกทอรีปัจจุบันคือ ~ (โฮมไดเร็กตอรี่)

UPDATE: นี่คือผลลัพธ์ตามความคิดเห็น:

$ gem -v
2.0.5
$ which gem
/Users/MyUserName/.rvm/rubies/ruby-2.0.0-p247/bin/gem

ฉันควรทำอย่างไรต่อไป


คุณแน่ใจได้ไหมว่า gem -v และ which gem ช่วยให้คุณถูกต้อง gem จาก RVM และไม่ /usr/bin/gem? คุณไม่ควรต้องใช้ sudo ด้วย RVM's gem.
slhck

ดูคำถามที่อัปเดตของฉัน (ส่วนล่าง) ฉันควรทำอย่างไรต่อจากการติดตั้ง Rails
Raptor

คำตอบ:


4

ตามที่ระบุไว้ในความคิดเห็นของฉันแรกตรวจสอบให้แน่ใจว่าทั้งสอง ruby และ gem ชี้ไปที่เวอร์ชันที่ติดตั้ง RVM ไม่ใช่เวอร์ชันที่ติดตั้ง /usr/bin.

ตรวจสอบให้แน่ใจว่าคุณใช้ทับทิมใหม่เป็นค่าเริ่มต้น:

rvm --default use 2.0.0-p247

สร้าง Gemset (เรียกว่า gemset ) ที่จะใช้สำหรับเวอร์ชั่น Ruby นี้:

rvm use 2.0.0-p247@gemset --create --default

จากนั้นติดตั้ง Rails ไปยัง Gemset:

gem install rails

ควรจะเพียงพอที่จะใช้ใหม่ rails รุ่น ลองรีสตาร์ทเชลล์ของคุณถ้ามันไม่ติด


เกือบจะ ฉันต้องการแทนที่ 2.0.0p247 กับ 2.0.0-p247 เพื่อติดตั้ง Rails ติดตั้งสำเร็จแล้ว!
Raptor

1
อาผิดพลาดเล็กน้อย ขอบคุณสำหรับการชี้แจงและดีใจที่คุณได้ทำงาน!
slhck

ฉันคิดว่าคุณต้องเพิ่มเส้นทางของ gemset ด้วย .bashrc. มิฉะนั้นจะไม่ติดเมื่อคุณรีสตาร์ทเชลล์
Kevin Chen

@ Kevin .bashrc ไม่มีที่มาจากการเริ่มต้นเชลล์ใน OS X คุณมักต้องการ .bash_profile. แต่ถึงอย่างนั้นหากมีการกำหนดค่า RVM อย่างถูกต้องการเลือก gemset นั้นไม่จำเป็น
slhck

0

ฉันเหนื่อย gem install rails --no-ri --no-rdoc หลังจากที่ฉันได้รับ:

Successfully installed rails-4.0.0
1 gem installed

ฉันเปิดหน้าต่างเทอร์มินัลใหม่แล้วลอง rails --version ... Rails 4.0.0 บางทีเวทมนตร์อาจจะเปิดหน้าต่างใหม่


1
ฉันยังกล่าวถึงการรีสตาร์ทเชลล์ โดยทั่วไปคุณจะต้อง "โหลดซ้ำ" คำสั่งที่ติดตั้ง
slhck

ไม่มีเวทมนต์ เป็นเพราะข้อผิดพลาดเกิดขึ้นขณะสร้างเอกสาร ดังนั้นหากคุณปิดใช้งานเอกสารไม่มีข้อผิดพลาด
Kevin Chen
โดยการใช้ไซต์ของเรา หมายความว่าคุณได้อ่านและทำความเข้าใจนโยบายคุกกี้และนโยบายความเป็นส่วนตัวของเราแล้ว
Licensed under cc by-sa 3.0 with attribution required.