In my project, we have a shell script that sets default values for some environment variables. When I try to run rinari-console, I receive an error because the script has not been sourced. Is there a way to make sure rinari sources it, so that when the rails console starts, all the variables have the needed values?
In my project, we have a shell script that sets default values for some
Share
Alright I’ve been thinkg a bit harder about the question. I’ve come up with two possible solutions:
Outside Emacs via wrapper
This solution is a bit clumsy, but it should work.
You could create a wrapper script, e.g. ’emacs-wrapper.sh’:
If you launch ./emacs-wrapper.sh, YOUR-SCRIPT.sh will be sourced and Emacs is started after that. The same environment will be visible to Emacs this way. Testing this approach on my machine, I was able to (getenv “var”) all variables defined in YOUR-SCRIPT.sh
Nicer: Within Emcas via shell-command
This is IMO a much nicer solution since it runs completely inside Emacs. Makes a call to shell-command-to-string to source your YOUR-SCRIPT.sh. At the end it also dumps that process’ environment. This is subsequently added to Emacs’ own process-environment:
I verified this approach on my machine as well. All variables defined in YOUR-SCRIPT were also defined in Emacs.