Find out where bash command definition is stored? - macos

I used make/cmake for a project a while ago to build a command line tool, and I thought the binary was only executable while in that directory, but I just found out I'm able to call the command from any directory. This is troublesome because I'm having trouble building a newer project and I suspect this is related.
For example, I can run the command caffe train from a specific folder where I built the binary, but it turns out I can run caffe train from any folder, which I shouldn't be able to do. I could delete the binary, but the problem is that the command for it is stored and being called from somewhere, but I don't know where.
How can I find out where the definition for this command is stored? I examined my .bash_profile and looked at all the paths it listed, but I'm not seeing a relevant one. Is there another place I ought to be looking to find where command line tools are installed?

Ah sorry I just found out: Using type command gives where it is stored. Apparently whereis command should also do the same thing, though it gives me no output; for anyone else who has this problem, trying both would be good!

Related

MSYS2: After integrating Git-For-Windows, I'm getting this error at MSYS2 startup: bash: create-shortcut.exe: command not found

I installed msys2, and then integrated the installation of Git-For-Windows within that msys2 environment, by applying this simple procedure.
After doing so, I'm getting this error when I double-click the msys2 desktop icon:
bash: create-shortcut.exe: command not found
bash: create-shortcut.exe: command not found
jdoe#msys2$
I can see where the above error originates :
The aforementioned procedure created this new script - /etc/profile.d/git-sdk.sh - which attempts to run the create-shortcut.exe command; but (like the script) I can't find where create-shortcut.exe is.
Does anyone know where that create-shortcut.exe comes from (MSYS2, MS-WINDOWS), or where it might be located? Or perhaps even know what the fix for this is? =:)
Thank you in advance.
Thank you to the commenters.
It's a bug, either because the referenced command wasn't included in the package, or because the command is not in the script's PATH. I'll file an issue in the GitHub project for it.
Thank you particularly to #HolyBlackCat for pointing out that the procedure wasn't necessary since git(1) is already available in MSYS2s default repositories. (I'm new to MSYS2 because I was provided a Windows environment instead of Linux). So, I ended up backing out the procedure and installing the native repository version instead, which works well.
However, if you did want to keep the version provided by the procedure -- because it does, indeed, offer more than just the git(1) command (e.g., it has an SDK too) -- then you can simply locate and safely comment-out the offending section in the /etc/profile.d/git-sdk.sh RC script, whose only purpose is to create a Windows desktop icon. Hopefully this helps others.

Cannot generate LaTeX from Isabelle/HOL under Windows7

I have spent too many hours trying to generate a .pdf document out of my Isabelle theory Increments.thy. The Isabelle build command gets stuck and apparently this is an installation thing on Windows. Frustratingly enough, friends have done this on their linux machines and they experience no problems at all. But I cannot find the right documentation to get it going on my Windows 7 laptop. Does anyone have the recipe?
I have a full LaTeX installation on my laptop, working like a breeze. I have installed CYGWIN, but it gave problems with access rights of files, that I couldn't solve (neither from the windows-end, nor from the cygwin-end). I tried various manuals, without much luck.
With some hands-on help of the university of Innsbruck, I could finally generate a pdf from an Isabelle theory on my Windows-7 laptop. I'd like to share the result for the community at large. Here is what I did to make it work:
In Microsoft Explorer, I went to the directory that contains the Isabelle executables. This directory is called Isabelle2016-1.
I found it by searching for Isabelle2016-1 in the file system. It is on C:\Users\sjo\AppData\Roaming\local\bin\Isabelle2016-1.
I checked that it contains the file Cygwin-Terminal.bat.
I called the file Cygwin-Terminal.bat by double-clicking it.
This opens a command-line interpreter (CLI), which is the GNU Bash interpreter.
In this CLI, I navigated to the directory that contains my Isabelle source code, Increments.sty, by issuing the command:
$ cd /cygdrive/d/git/Publications/2017AFPproofs
I used the command ls -al to verify that this directory contains my Isabelle source code file Increments.thy.
I generated a pdf-file D:\git\Publications\2017AFPproofs\output\document\root.pdf by calling Isabelle:
$ isabelle build -v -D .
I checked the result in Microsoft Explorer and displayed it with my pdf-viewer.
That worked.

How to add the path variable in XCode 4.6 to use /usr/local/bin

When compiling a project with an external build environment (scons) in XCode I run into the the issue that XCode can't find protoc which is in the /usr/local/bin directory.
sh: protoc: command not found
How can I add this path variable to sh / xcode
I seem to run into this periodically so about 6 months ago I began keeping an error journal so I wouldn't start from scratch trying to figure out what was wrong.
So for this I had two answers written down:
Change the Install Directory of the Library to $(BUILT_PRODUCTS_DIR) and change the Library Search Paths and the User Header Search Paths of the target to $(BUILT_PRODUCTS_DIR (recursive)
I hope this does it for you, good luck.
I implemented a shell script that adds the path locally and run this instead of the external build tool. This script first sets the path and flags and then later simply calls the external build environment scons.
Not pretty but works...

Using Google's ProtoBuf (and a .proto file) to create a Python API Library

I have the .proto file used in the open-source Android API (http://code.google.com/p/android-market-api/), and am having some trouble compiling the file to generate the .py.
I'm trying to follow the instructions here, https://developers.google.com/protocol-buffers/docs/pythontutorial , and am on the steps that are under the header "Compiling Your Protocol Buffers".
I've downloaded the compiler, protoc.exe. The readme says "To install, simply place this binary somewhere in your PATH," which I'm not understanding. I'm messed around with it for a while now, but can't think of how to proceed.
I'm quite the novice programmer, so please tell me if something isn't clear, or if I'm having some sort of fundamental misunderstanding... about anything. I'm on Windows 7 by the way.
Thanks!
if protoc.exe is not in the same directory you're calling it from, you need to add it to your PATH environment variable to be accessible from the calling directory when you're in the shell. open up a command shell and execute:
set PATH=%PATH%c:\directory\to\proto\executable;
then change directories over to where your source code is and execute the compilation line as instructed from the google page.
I had the same problem because it is not written that clear in the README.txt. What they mean is to:
1. take the protoc.exe and put it in the same folder with the other files of your project.
2. open the cmd to that directory and run: protoc --cpp_out=. myfile.proto
=> This will create the 2 new files in the folder with the files of your project, and then you can add them normally to your program.
This helped me: http://www.scriptol.com/programming/protocol-buffers-tutorial.php
This is for c++, but I guess it will be something similar for python; I guess you just have to change the command you are using in the cmd :)

Configuring Bison to compile an input file under Visual C 6

I'm trying to get Bison to do it's thing in VC6. I'm sure this must be a problem with my configuration. At the moment I have a Custom Build step as follows.
<Commands>
echo Start parser generation
"C:\GnuWin32\bin\bison.exe" $(InputPath)
echo Finish parser generation
<Outputs>
$(ProjDir)\$(InputName).c
$(ProjDir)\$(InputName).h
The error I get is "C:\GnuWin32\bin\bison.exe: m4: No such file or directory", which makes me think the m4.exe doesn't exist or isn't on the path, but I can run the exact same command from CMD in the same directory with no errors.
This thought process makes me think it's a problem with the output options, but I've tried various configurations with no luck.
Any help would be great, thanks in advance.
Edit: I've added some more visual studio versions to the tag list to try to get some more exposure for the question. Hopefully someone will have done this in a later version and I can work backwards.
Okay, I've managed to slove this in a very round-about way but I will try my best to document it here.
It seems that VC6 Custom build options will only look in the project directory for the m4.exe, even when you specify where the calling exe (bison) is explicitly. To solve this I did a bit of a hack and did a full cd command in the custom build window to get to the gnuwin32 directory (where both bison and m4 live) before trying to call the parser generator.
This works fine but is a bit of a hassle for trying to distribute it to other people when they may have installed GNU tools to a different location.

Resources