32

I am getting started with Meteorjs. I'm a windows user so I downloaded the windows installer package Release 0.7.0.1-win2. I use gitbash for my command line interface and can't get it to recognize meteor. I get the error "sh.exe": meteor: command not found". It works fine in windows command line but I prefer gitbash.

How do I get meteor to work with gitbash?

Dustin Fraker
  • 524
  • 1
  • 5
  • 9

5 Answers5

84

I have the perfect answer for you since I literally just solved the issue myself.

First of all make sure meteor works in the default windows command prompt. Next open git bash and check if the following command works:

cmd //c meteor

This runs the command meteor as if you were in the command prompt.

Next step is to set up an alias in git bash so you don't have to type that out each time.

Open git bash and enter the following:

vim ~/.bashrc

this will open/create the bashrc file in VIM, press i to insert and type the following:

alias meteor="cmd //c meteor"

Save and exit vim by first pressing the Esc key then press the ":" key. Now you should be able to enter commands in VIM. Type "wq" and press enter which will write into your .bashrc file and exit vim.

Almost there! Now that you are back in git bash, all you need to do is point to your .bashrc file by entering the following:

source ~/.bashrc

Now you will be able to run meteor commands straight from git bash! Hope that helped!

Huan Zhang
  • 1,095
  • 8
  • 13
  • 1
    This worked perfectly for me. Except I simply opened .bashrc with sublimetext instead of vim. But that is just a preference thing after all. Thanks! – MartinJH Aug 04 '15 at 18:55
  • 1
    no problem, just wanted to share this since I couldn't find a solution anywhere when I had the problem! – Huan Zhang Aug 04 '15 at 23:49
  • Worked for me! But I had to do `source ~/.bashrc` instead of `source .bashrc` – user3413723 Aug 19 '15 at 00:03
  • hello, thanks for pointing that out. You are right since I assumed that you are already in the home directory in the terminal thus I omitted the ~/. Will amend my answer. – Huan Zhang Aug 20 '15 at 16:49
  • This should be marked as an answer as it solves the problem (even though vim is a bit of a diversion) – Shane Sep 15 '15 at 13:13
  • Yeah I agree, its a bit of a work around, but hey we live in an imperfect world :) – Huan Zhang Sep 16 '15 at 14:02
  • This worked for me as well. Any idea why just adding it to the path didn't work? – stringo0 Sep 03 '16 at 22:08
  • Not 100% sure but I think since gitbash is trying to mimic BASH in windows, it cannot directly run the windows version of meteor. My method bypasses this by simply telling gitbash to run meteor in command prompt. – Huan Zhang Sep 04 '16 at 01:34
  • for creating .bashrc file on window please refer http://stackoverflow.com/questions/6883760/git-for-windows-bashrc-or-equivalent-config-files-for-git-bash-shell – RIYAJ KHAN Apr 14 '17 at 09:41
2

Here's the fix:

The problem is because of .bat files not being handled properly by MinGW

Go to this directory - C:\Users[your username]\AppData\Local\.meteor You should see a meteor.bat file there. Create a new file called "meteor" (without any extension and ""). Open it with notepad and paste the following:

#!/bin/sh
cmd //c "$0.bat" "$@"

save the file and now run git bash. You should be able to use meteor command in git bash.

Details

To run a *.bat command from MinGW's MSYS shell, you must redirect the execution to cmd.exe, thus:

cmd //c foo.bat [args ...]

The foo.bat command file must be in a directory within $PATH, (or you must specify the full path name ... using slashes, not backslashes unless you use two of them for each path name separator). Also, note the double slash to inform cmd.exe that you are using its /C option, (since it doesn't accept the -c form preferred by the MSYS shell.

If you'd like to make the foo.bat file directly executable from the MSYS shell, you may create a two line Bourne shell wrapper script called simply foo alongside it, (in the same directory as foo.bat), thus:

#!/bin/sh
cmd //c "$0.bat" "$@"

(so in your case, you'd create script file meteor alongside meteor.bat).

In fact, since this wrapper script is entirely generic, provided your file system supports hard file links, (as NTFS does for files on one single disk partition), you may create one wrapper script, and link it to as many command file names as you have *.bat files you'd like to invoke in this manner; (hint: use the MSYS ln command to link the files).

Credits to: Keith Marshall on SO and rakibul on Meteor Forums

Community
  • 1
  • 1
Dheeraj Bhaskar
  • 18,633
  • 9
  • 63
  • 66
  • I've tried this on Windows 10 (creating the new `meteor` file), and Git Bash still says "meteor: command not found". It's installed on the standard Windows command line, but like OP I develop with Git Bash. This may be related: when I open the Windows command line, it opens in `C:/Users/MyName` instead of `C:/` – Yami Medina Jan 29 '16 at 00:01
  • @YamiMedina without actually doing a teamviewer to your box, I wouldn't be able to reason why it's not working for you. If you've any updates to your situation, or have found a fix, please post here. – Dheeraj Bhaskar Feb 15 '16 at 09:14
1

It shouldn't be too hard - you just need to make sure that the meteor.bat file is in your executable. Check with echo $PATH from the bash console if it is already there.

For me, the meteor 0.7.0.1-win installer appended meteor's folder to the path automatically. However, you can add it manually with:

export PATH=$PATH:/path/to/user/folder/AppData/Local/.meteor

(On CygWin my user folder is at /cygdrive/c/Users/adam - I'm not sure what the equivalent path would be on git bash).

If you like, append that line to your ~/.profile to make sure meteor gets added to the path when the console opens.

Finally, on Windows the executable file is meteor.bat. I made a symbolic link to the filename meteor, just so I wouldn't have to type the .bat:

cd /path/to/user/folder/AppData/Local/.meteor
ln -s meteor.bat meteor.
Adam Brown
  • 1,056
  • 10
  • 13
1

Please have a look at the issue https://github.com/sdarnell/meteor/issues/18

I would suggest maybe creating a trivial wrapper script or alias that invokes LaunchMeteor.exe with the original arguments.

StephenD
  • 3,662
  • 1
  • 19
  • 28
0

After more research on google I see that there isn't an implemented way to do this yet. The guys at meteor are working on it and accepting pull requests if you have a solution. The conclusion I came to is to use Vagrant and virtualbox to set up a ubuntu vm for meteor development. You can find info at this site: http://win.meteor.com/ on how to install virtual machines and provision to work with meteor.

Dustin Fraker
  • 524
  • 1
  • 5
  • 9