Reputation: 1231
I have a Rails project with a rake task called update_data
, which is as follows:
every 1.day, :at => '2:30 am' do
root = File.expand_path('../..', __FILE__)
system("""(source #{root}/data_scripts/venv/bin/activate;
python #{root}/data_scripts/scripts/main.py;
deactivate)""")
end
This should first activate the virtualenv, run the script, and then deactivate the virtualenv.
When I run rake update_data
, this works perfectly. However, when I run heroku run rake update_data
, it fails with sh: 1: source: not found
. What should I do so that source
is available on Heroku?
Upvotes: 0
Views: 212
Reputation: 2934
The error message sh: 1: source: not found
means that:
sh
instead of bash
,source
is not a built-in command and the shell isn't able to find source
in PATH
.To confirm this run heroku run sh
, type source
and compare the output with trying to execute foobar
.
I recommend you try passing the command to bash (via `bash -c "your command goes here"). You may also need a Python buildpack. You can add it with:
heroku buildpacks:add heroku/python
Upvotes: 2
Reputation: 192
I feel like you don't need to activate your virtualenv.
Just use the virtualenv's python executable:
every 1.day, :at => '2:30 am' do
root = File.expand_path('../..', __FILE__)
system("#{root}/data_scripts/venv/bin/python #{root}/data_scripts/scripts/main.py")
end
Upvotes: 0