NoMethodError с Ruby при установке клиента SoundCloud 2000 для CLI

324
Alison

Я пытаюсь установить SoundCloud2000 на мой MacBook под управлением Mac OS X 10.8.5.

У меня есть Ruby 2.2.0 mpg123, и portaudioустановлен. Установка SoundCloud 2000 в качестве GEM, кажется, работает нормально:

gem install soundcloud2000 

Но потом, когда я пытаюсь использовать его из командной строки при запуске $soundcloud2000- вместо клиента я получаю следующую ошибку:

/Library/Ruby/Gems/1.8/gems/soundcloud2000-0.1.0/lib/soundcloud2000.rb:1: undefined method `require_relative' for main:Object (NoMethodError) from /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require' from /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/rubygems/custom_require.rb:31:in `require' from /Library/Ruby/Gems/1.8/gems/soundcloud2000-0.1.0/bin/soundcloud2000:3 from /usr/bin/soundcloud2000:19:in `load' from /usr/bin/soundcloud2000:19 

Я не знаю, что это значит. Кто-нибудь еще знает?

1

1 ответ на вопрос

0
JakeGould

You say you have Ruby 2.2.0 installed, but looking at the error all of the references are for /Library/Ruby/Gems/1.8/gems/ which means SoundCloud 2000 is installed as a Ruby 1.8 GEM. So my guess is however you installed Ruby 2.2.0 that is not the main ruby you are running from the command line. You can confirm with version of Ruby you are running on your Mac by running this command:

ruby -v 

The output should be something like this; note on I am running Mac OS X 10.9.5 so my installed version of Ruby will be higher than Mac OS X 10.8.5:

ruby 2.0.0p481 (2014-05-08 revision 45883) [universal.x86_64-darwin13] 

You can also see where your version of Ruby is being loaded from via which like this:

which ruby 

The output should be something like this:

/usr/bin/ruby 

The which tool tells you exactly what path the binary you are calling via that command is being loaded from.

Since it seems like you are using Homebrew to install a newer version of Rub, you need to also make sure your user’s $PATH is set to check /usr/local/bin before checking /usr/bin. This is typically set in the .bash_profile file in your home directory which is located via ~/.bash_profile. Just note that this stuff might also be set in a file named .bashc, so adjust the examples to use .bashc instead of .bash_profile if that is the case.

For example, if I run the following command on my Mac OS X setup:

cat ~/.bash_profile 

I see these contents:

export PATH="/usr/local/sbin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/opt/X11/bin:/usr/local/git/bin:/opt/ImageMagick/bin" 

Might look complex, but it isn’t. All that command does is basically set the $PATH settings for your shell environment. And the items between the quotes are just directory paths separated by : characters. Of note to you this the order of /usr/bin versus /usr/local/bin; one comes in front of the other. Which basically means the system will check for ruby in /usr/bin and prefer to use that one before it even reaches the ruby installed via /usr/local/bin. So a quick fix for you would be to take /usr/local/bin and place it in front of /usr/bin via a text editor like nano. Then save it, exit your Terminal session and open a new one.

That said, if I were you I would recommend avoiding system level Ruby and Ruby GEM installs via Homebrew and rather use RVM (Ruby Version Manager) instead. Ruby—and Ruby GEMs—can actually be a pain to deal with on a good day; and even a worse of a headache on a Mac. So using RVM instead can allow you to create isolated Ruby and Ruby GEM installs specific to your user that are easier to manage.

I do Linux systems administration and tend to want to upgrade the version of Ruby installed by default and used to do that via source or package installers. But the more work I do on Ruby setups, the more I’ve realized that RVM is really the best way to install, manage and deal with Ruby setups. Slight learning/understanding curve when you first set it up but past that it will make your life—and system management—tons easier.

Вы правы @jakegould, который говорит, что я использую ruby ​​1.8.7. Я пытаюсь установить более новую версию с помощью `brew install ruby` Alison 9 лет назад 1
@ Элисон Бинго! Посмотрите мои последние изменения, где я объясняю, как это можно исправить, настроив `$ PATH` в системе. И я также рекомендую избегать использования Homebrew для Ruby и использовать RVM (Ruby Version Manager). JakeGould 9 лет назад 0
@Alison Мне жаль, что вы сталкиваетесь с этими проблемами, но размещать подобные сообщения об ошибках в комментариях плохо. Не читается и сложен в управлении. Лучше, если вы измените свой вопрос, чтобы опубликовать свои новые проблемы и проблемы, с которыми вы сталкиваетесь при установке SoundCloud 2000. JakeGould 9 лет назад 0
о хорошо, извините за это, буду делать @jakegould Alison 9 лет назад 0
Также, если вы сейчас используете Ruby 2.2.0, вам придется переустановить `mpg123` и` portaudio`, чтобы они использовали Ruby 2.2.0 вместо 1.8.7. Также, пожалуйста, проверьте обсуждение этой ошибки в официальном репозитории SoundCloud2000. https://github.com/grobie/soundcloud2000/issues/69 JakeGould 9 лет назад 0
аааа, отлично, вот в чем проблема. Большое спасибо за вашу помощь @jakegould, это неоценимо !! Alison 9 лет назад 0
@Alison Добро пожаловать! Рад, что помог. Если мой ответ был полезен для вас, пожалуйста, не забудьте высказать его. И если это ответ, который решил вашу проблему, пожалуйста, отметьте его, когда это возможно. JakeGould 9 лет назад 0
спасибо @jakegould, я не могу отозвать это, потому что я не был на бирже стека достаточно долго / не имею репутации, чтобы поднять, но я проверил это. Еще раз спасибо за вашу помощь! Alison 9 лет назад 1