heroku, bash: rake: command not found ,Windows 10 - ruby

I have searched through the slack forums and nothing seems to be working for my instance!
A little background; I am working with a Angular1, Heroku-Postgresql, Nodejs, Ruby&Rails application. Previously developed by someone else and has been passed down to me.
When I run in Windows Powershell
heroku rake db:migrate -a [app]
my console returns
Running rake db:migrate on [app]... up, run.7474 (Free) bash: rake: command not found
I have tried "heroku run rake db:migrate", does not work.
Installed bash on ubuntu on windows, added appropriate gem files, heroku, etc. created a symbolic link sudo ln -s /var/lib/gems/1.8/bin/rake
& still get bash: rake: command not found
Tried to run rake inside the heroku bash shell, and still get 'not found'.
Updated gemfiles, ruby files, added ruby bin to my environment variables.
So what gives? I am not familiar with Bash Ubuntu. Any guidance on what steps to take/try would be tremendous help.

You're running that command on heroku platform.
And, as seen on documentation, you should run your command as
heroku run rake db:migrate -a [appname]
My guess would be that you have something in some script that tries to execute rake.
You can use the --trace argument to see the detailed execution.

Related

create Scheduled Task from working Ruby script on Ubuntu inside Windows10

I have a Windows10 Ubuntu bash environment set up. It has a few rubygems installed (without docker, bundler, without rvm, and also this is not rails). The script is working fine when I run it manually from inside the Ubuntu terminal, in the user home folder ~/
Now my goal is create a Windows Scheduled Task using the Task Scheduler application, to run the script daily, like I would with a crontab in Unix.
The action in this Scheduled Task is the challenge. In testing manually from the Windows CMD prompt, I got as far as:
C:\>C:\Windows\System32\bash.exe -c "ruby ~/myscript.rb"
That fails :
Traceback (most recent call last):
2: from /home/lam/ruby/remind_prepare_dad_before_iterative_ends.rb:15:in `<main>'
1: from /usr/lib/ruby/2.5.0/rubygems/core_ext/kernel_require.rb:59:in `require'
/usr/lib/ruby/2.5.0/rubygems/core_ext/kernel_require.rb:59:in `require': cannot load such file -- tiny_tds (LoadError)
Above error tells me it cannot find my gem, TinyTDS. What do I add to the command line to make it find my gems?
I found a crude workaround for my own problem: just install the gem from the same command line:
C:\>C:\Windows\System32\bash.exe -c "sudo gem install tiny_tds"
I had to re-install a few more gems I use in the same way.
After this, I put in a -C argument to start ruby in the right directory, like so:
C:\>C:\Windows\System32\bash.exe -c "ruby -C ~/ruby myscript.rb"
works like a charm.
I suppose now I have duplicated gems floating in spaces on the machine, but we will address that issue if it ever becomes a problem. :-)
Try bundle exec ruby ~/myscript.rb

Heroku: where did my gems go?

I have been deploying a Rails 3.2 application to heroku for several weeks now. I have also been executing rake tasks on the Cedar stack where my application is located.
One day after a deploy I noticed that rake was no longer working. I get, for example, the following:
$:~/dev/my_project$ heroku run rake -T
Running `rake -T` attached to terminal... up, run.7566
bundler: command not found: rake
Install missing gem executables with `bundle install`
Trying to run commands with bundle exec yields the same results.
What I've tried:
heroku run bundle install. This works and informs me that gems were installed into ./vendor/bundle. However, heroku run ls ./vendor/bundle yields only the following:
$:~/dev/my_project$ heroku run ls ./vendor/bundle/
Runningls ./vendor/bundle/attached to terminal... up, run.3458
bin ruby
bundle package. Although the deployment works it does not help my problem.
fiddling around with the rubygems-bundler gem (although I think this is now part of core bundler). This does not seem to have any effect.
On Heroku, gems are installed within the vendor/bundle/ruby/<version>/gems directory. I just checked my Heroku instance and confirmed this.
You are going to want to use bundle exec rake task because the gems are not in the users PATH.

Problems with heroku toolbelt

I'm absolute newbie in Ruby and Rails project, so I'm sorry if this is dumb question.
I've installed heroku toolbelt using wget -qO- https://toolbelt.heroku.com/install-ubuntu.sh | sh. Also I tried gem install heroku. But when I type:
MY_USER#home-PC:~$ heroku version
<internal:gem_prelude>:1:in `require': cannot load such file -- rubygems.rb (LoadError)
from <internal:gem_prelude>:1:in `<compiled>'
I've checked in google and people suggest that gem and current ruby are different versions so I've checked it and they seem to the same:
MY_USER#home-PC:~$ which ruby
/home/MY_USER/.rvm/rubies/ruby-1.9.3-p327/bin/ruby
MY_USER#home-PC:~$ gem env | grep 'RUBY EXECUTABLE'
- RUBY EXECUTABLE: /home/MY_USER/.rvm/rubies/ruby-1.9.3-p327/bin/ruby
I have no idea what to do more, so please help.
Sorry for the maybe stupid question, thanks in advance.
EDIT:
Forgot to say I'm running Ubuntu 12.10.
The problem is that the heroku executable you installed probably starts with a line like this:
#!/usr/bin/ruby
This will force the heroku command to always use the system-wide ruby (/usr/bin/ruby) and it will never run your rvm version of ruby.
To fix it simply edit the first line of the heroku script to this:
#!/usr/bin/env ruby
This will make the heroku command run whichever ruby command is in the current PATH, instead of a hard coded path like previously.
To find the location of the heroku script, so you can edit it, simply type:
which heroku
It should print out the location of the script so you can find it and load it into your editor.
Also if you do not have write permission you may enter:
:w !sudo tee % > /dev/null
to save successfully .

bundle command not found heroku

I am trying to use ruby 1.8.7 in my heroku application but the application does not launch. Heroku shows following errors in the console:
2012-10-30T13:29:08+00:00 app[web.2]: bash: bundle: command not found
heroku run "bundle --version" also returns in command not found:
heroku run "bundle --version"
Running `bundle --version` attached to terminal... up, run.1
bash: bundle: command not found
Any ideas on what might be issue here ?
The code will look like this with the newest version:
heroku config:add GEM_PATH=vendor/bundle/1.8
Have you installed a new ruby version? Good chance that ruby version doesnt have bundler installed, use
heroku run 'gem install bundler'
after installing a new ruby!
You need to have the supported Ruby buildpack set:
heroku buildpacks:set heroku/ruby

How do I replace the Heroku gem with Heroku Toolbelt?

I know that there are closely related question to mine but they did not help me.
I'm learning the whole rails, gem, git, heroku concept and liking it a lot.
When I issued heroku command line actions (Ubuntu linux) I received warnings that the gem was deprecated and I should install the toolbelt.
I ran the full wget install of the tool belt:
wget -qO- https://toolbelt.heroku.com/install-ubuntu.sh | sh
But now when I use the heroku command line I still get the deprecated warning.
I suspect I have to get rid of the heroku gem but I'm not sure how to do that ? I want to be sure to do it correctly so it's not later loaded again via bundler.
Thank you.
The uninstall command will remove any gem. In this case, you want to use the following:
gem uninstall heroku
I had issues getting Toolbelt to work. I am running OSX so my solution may not work for your Ubuntu linux setup. I still thought I might share just in case. Here are the steps I used to get it to work:
Remove the heroku gem by running gem uninstall heroku. It did ask if I wanted to remove executables: heroku. Be sure to choose yes.
Go to [https://toolbelt.heroku.com/][1] and download / install the Toolbelt app.
On the Toolbelt page it mentioned that /usr/local/heroku/bin will be added to your PATH. I was not seeing this and was not sure if it is becuase I am running zsh instead of bash. I went ahead and opened my .zshrc file and added it to my PATH.
You probably just need to relaunch your shell.
This worked for me: (be sure to choose yes when it ask if you want to remove executable: heroku)
gem uninstall heroku --all
Source (last comment): http://johntwang.com/blog/2011/09/13/remove-heroku-toolkit/

Resources