2

I installed osx-trash using the answer here but got the error:

/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:45:in `require': cannot load such file -- osx/cocoa (LoadError)
    from /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:45:in `require'
    from /Library/Ruby/Gems/2.0.0/gems/osx-trash-1.0.0/bin/trash:35:in `<top (required)>'
    from /usr/bin/trash:23:in `load'
    from /usr/bin/trash:23:in `<main>'

Seems that Ruby 2.0 on newer Mac OS X no longer supports the "osx/cocoa" module and people recommend changing the script to run with Ruby 1.8 which I already have on my system. I edited /usr/bin/trash to change the first line to run the script as 1.8:

simbo$ diff /usr/bin/trash /usr/bin/trash.bak 
1c1
< #!/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby
---
> #!/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/bin/ruby

But now I get the error:

/Library/Ruby/Site/1.8/rubygems/dependency.rb:247:in `to_specs': Could not find osx-trash (>= 0) amongst [activesupport-3.2.13, .... uuidtools-2.1.2, vmc-0.3.18, vmc-0.3.14] (Gem::LoadError)
    from /Library/Ruby/Site/1.8/rubygems/dependency.rb:256:in `to_spec'
    from /Library/Ruby/Site/1.8/rubygems.rb:1203:in `gem'
    from /usr/bin/trash:22

I think that this may mean that the original command to install the gem which I ran from the link above installed things for ruby 2.0 so running the script on ruby 1.8 has missing dependencies.

How do I fix the installed osx-trash script to be run properly?

1

If you have ruby 1.8 in your system then you should also have gem 1.8, in which case I think this should work:

sudo ln -s /Library/Ruby/Gems/1.8/gems/rubygems-update-1.8.12/bin/gem /usr/bin/gem18
sudo gem18 install osx-trash

now with the edit to the top of the trash script to use ruby 1.8 things will work.

| improve this answer | |
  • had to create a symlink to gems to get your answer to work. once my edit has been approved i will accept the answer. thanks. – simbo1905 Jan 4 '14 at 7:37
  • Hi @simbo1905, I approved your edit, thanks, and I'm glad it works! – janos Jan 4 '14 at 7:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.