Rails - Amazon aaws LoadError; .bash_profile snafu
I have been working with the Amazon aaws 0.8.1 gem, with direction from: http://www.jeffreyjason.com/2010/07/12/amazon-product-advertising-api-w-ruby/
First, I installed the gem by adding gem ruby-aaws
in my gemfile, then bundle installing and it installed successfully.
Then I added the necessary information outlined in the article to my .amazonrc
file and saved it in my home directory.
Then I tried to run his sample script to make sure everything was ok:
开发者_如何学运维require 'amazon/aws/search'
include Amazon::AWS include Amazon::AWS::Search
resp = Amazon::AWS.item_search( 'Baby', { 'Keywords' => 'pants',
'MinimumPrice' => '2500',
'MaximumPrice' => '4999' } )
items = resp.item_search_response.items.item
items.each { |item| puts item, '' }
And I get the error: 'require': no such file to load — amazon/aws/search (LoadError)
This seems to be a common enough error because he addresses it at the bottom of his tutorial by saying: solution: don’t forget to set RUBYOPT in your .bash_profile via: export RUBYOPT=rubygems
I tried searching for the .bash_profile file and couldn't find it. I made sure hidden files were shown, and still nothing. So I created one and added it into my home directory, but the problem still persists.
Most of the resources online address .bash_profile in Linux or Mac environments, but I am running a windows vista OS (and rails 3.0.7 for further clarity).
Any ideas on how to solve the .bash_profile conundrum and successfully connect to the amazon db's?
Thanks in advance!
.bash_profile
is not on window's OS's, so trying to find the .bash_profile is a fool's errand. The real question is how to modify RUBYOPT
on a windows system (which it seems the .bash_profile/.bashrc
is used for on other OS's).
First, close down your ruby command line if its open, and go to the Start Menu
, then the Control Panel
-> System
->Advanced Settings/System Properties
.
In the Properties
section click the Advanced
tab and click the environment variables
button at the bottom right.
Under Environment Variables
, create a new variable with the name "RUBYOPT"
and the value "rubygems"
then reopen your ruby command line.
精彩评论