TLDR: Basically RubyMine does not recognize any user created environment variable when launched from a desktop entry, but when launched from console (using $ mine
) it can recognize all the environment variables. What could be wrong?
I am using Google Cloud Vision API and I've already set GOOGLE_APPLICATION_CREDENTIALS
environment variable to my service account private key file path.
When I launch RubyMine
from a desktop entry and run the code below.
require 'google/cloud/vision'
image_annotator = Google::Cloud::Vision::ImageAnnotator.new
response = image_annotator.text_detection(
image: "path_to_image_file",
max_results: 1
)
It throws a Runtime Error
:
Traceback (most recent call last):
7: from /home/burak/RubymineProjects/covid19/main.rb:17:in `<main>'
6: from /home/burak/.rbenv/versions/2.6.3/lib/ruby/gems/2.6.0/gems/google-cloud-vision-0.38.0/lib/google/cloud/vision.rb:169:in `new'
5: from /home/burak/.rbenv/versions/2.6.3/lib/ruby/gems/2.6.0/gems/google-cloud-vision-0.38.0/lib/google/cloud/vision/v1.rb:166:in `new'
4: from /home/burak/.rbenv/versions/2.6.3/lib/ruby/gems/2.6.0/gems/google-cloud-vision-0.38.0/lib/google/cloud/vision/v1.rb:166:in `new'
3: from /home/burak/.rbenv/versions/2.6.3/lib/ruby/gems/2.6.0/gems/google-cloud-vision-0.38.0/lib/google/cloud/vision/v1/image_annotator_client.rb:122:in `initialize'
2: from /home/burak/.rbenv/versions/2.6.3/lib/ruby/gems/2.6.0/gems/googleauth-0.12.0/lib/googleauth/credentials.rb:329:in `default'
1: from /home/burak/.rbenv/versions/2.6.3/lib/ruby/gems/2.6.0/gems/googleauth-0.12.0/lib/googleauth/credentials.rb:361:in `from_application_default'
/home/burak/.rbenv/versions/2.6.3/lib/ruby/gems/2.6.0/gems/googleauth-0.12.0/lib/googleauth/application_default.rb:76:in `get_application_default': Could not load the default credentials. Browse to (RuntimeError)
https://developers.google.com/accounts/docs/application-default-credentials
for more information
But when I run the code from within IRB
or when I launch RubyMine
from console and run the same code, it runs successfully.
GOOGLE_APPLICATION_CREDENTIALS
where? How? – muru May 29 '20 at 08:50export GOOGLE_APPLICATION_CREDENTIALS=path_to_file
in.bashrc
– Burak Kaymakci May 29 '20 at 09:06GOOGLE_APPLICATION_CREDENTIALS=path_to_file
without the export in~/.pam_environment
instead. The GUI doesn't read your .bashrc. – muru May 29 '20 at 09:16