I'm trying to figure out how (and if it's possible) to tell brew that when person x installs my package it has to put some files in a folder and some in others.
For example you usually use /etc/ folder for config files: let's say i have project "project" like
file1.py
file2.js
file3.blablabla
configfile.conf
and i want that when someone launches brew install project file 1, 2 and 3 get put inside default brew folder while configfile.conf gets moved in /etc/project/. I have seen many packages moving files around during installation, but brew's docs don't cover this case and looking it up on google results only in people asking how to move homebrew installation folder.
Is this possible or do i have to organize the whole project inside the same folder?
I finally found the answer, it was not well explained in the docs, but was there:
Here are the docs
The answer is under "just moving some files" section:
Inside your .rb script, you have the def install function. If you look at the docs there is a table containing lots of directories
prefix #{HOMEBREW_PREFIX}/Cellar/#{name}/#{version} /usr/local/Cellar/foo/0.1
opt_prefix #{HOMEBREW_PREFIX}/opt/#{name} /usr/local/opt/foo
bin #{prefix}/bin /usr/local/Cellar/foo/0.1/bin
etc...
These are the directories where you can install files.
For example i had to move my script inside bin folder and a config file inside etc folder, so i wrote
def install
etc.install "config" # move file "config" to etc directory
bin.install "script" # move file "script" to bin directory
end
N.B.: etc and bin are not /etc/ and /bin/ but those specified inside brew's docs. In this case #{HOMEBREW_PREFIX}/etc and #{prefix}/bin where HOMEBREW_PREFIX is /usr/local and prefix is brew's installation folder.
Related
I have a local Go project which requires another data file to live with it, as in
my_project/
go.mod
my_tool.go
data.txt
go.mod:
module my_project/my_tool
go 1.19
Until today, I had the path to my_project directory inserted in the $PATH environment variable so I could build the executable file with go build and run it from anywhere.
Then I wanted to try and run go install (with no arguments, as shown in this tutorial) from my_project directory. So I did and noticed that the command does two things:
go install builds the executable file just like go build does;
go install moves the executable file —the file itself, not its symlink— to the $GOPATH/bin directory.
But the go install command does not put any other project file to $GOPATH/pkg/mod — which is a no-go for my tool which requires its buddy data.txt file to be located in the same filepath.Dir(os.Executable()) directory as the executable file.
Neither does the go install my_project/my_tool command. Hence the question:
Is it possible to install a local Go package in the $GOPATH directory in such a way that it can find the location of the other files belonging to the project without me having to add the project directory to $PATH?
I would like to release my program that wrote in ruby language, I need to pack ruby to appimage file and send it to my client ubuntu PC first.
so I create the folder "ruby-img", then copy my compiled ruby which in "/app/ruby" folder to "ruby-img/app/ruby" and then made a link as "ln -r -s app/ruby/bin/ruby usr/bin/." in "ruby-img" folder.
then I create the desktop file and put png file to "ruby-img", using appimagetool to create ruby-x86_64.AppImage. sadly it can not run, AFAIK that ruby.AppImage still using /app/ruby/lib folder to find some library of ruby but not in "ruby-img/app/ruby/lib" related folder.
so I tried re-compile ruby as --prefix=/tmp/ruby or --prefix=/usr/local/ruby, then copy them to "ruby-img/usr/local/ruby" or "ruby-img/tmp/ruby" then maka some link as above, and repack to AppImage but ruby.AppImage still not working...
any idea can help me ?
AppImages contain of a filesystem with all the content you provide plus a small executable stub that will mount the AppImage filesystem, then run the AppRun executable to be found inside.
With that knowledge it is utmost important that you provide an executable in the root directory along with the .desktop and icon files. I suggest you do not create AppRun yourself. Use the precompiled one from https://github.com/AppImage/AppImageKit/releases/tag/continuous (do not forget to rename it to exactly 'AppRun').
Now when this AppRun gets invoked, it will perform a few checks, cd into the /usr directory and try to start the executable specified in the .desktop file. Check it's source code and you can see that it also sets a few environment variables.
Therefore it is best you provide your entrypoint as /usr/bin/ruby.sh and register that in the desktop file. Remember if /usr/bin/ruby.sh gets called, the current work directory is /usr. So ruby.sh can set further environment variables such as LD_LIBRARY_PATH so that the libraries you configured for /usr/lib will actually be loaded.
With that I hope you have at least as much success as I had.
I have installed go package. When I go to the instance(VM) and run the command
go get github.com/linkedin/Burrow from a terminal/cmd it is downloading both "src" & "bin" folder under user home directory. But when I run the same command by setting GOPATH in a shell script, it is only downloading the "src" folder but not generating "bin" folder.
SOURCE_DIR="/opt/burrow"
export GOPATH=$SOURCE_DIR/go
go get $BURROW_REPO
Am I missing anything?
Use go install command (Compile and install packages and dependencies).
That command download src to $GOPATH and build it to $GOBIN.
GOBIN may not be set at the moment.
You can check by go env GOBIN. if its empty so you must set with export GOBIN=$(go env GOPATH)/bin
Also, for calling binary files from your terminal, you need to use go install command. This will create related bin file under GOBIN path.
There's a lot going on here.
The first point of your confusion is that go get does not download neither "src" nor "bin": Go packages are always contain only source code, and they typically does not contain the "src" directory in their file and directory hierarchies.
Instead, these directories are artefacts of the the Go toolchain.
The second point of confusion is that since Go 1.8, the Go toolchain uses a fallback value for the GOPATH environment variable if that is not set, and on Unix-like systems it defaults to the directory named "go" under the "home" directory of the user executing the go command.
If this directory is missing, the toolchain will create it.
Hence my stab at your problem is that you have some sort of permissions problem: when GOPATH is unset, "$HOME/go" is used — with whatever value $HOME expands to for the current user; when you set GOPATH by hand, something prevents creation of the "bin" directory under $GOPATH.
There's another possibility: you also set the GOBIN environment variable, which, when set, overrides the usual location used to install binaries built by go install (and go get).
You might study the output of go help environment to read more on the subject.
In either case, the most sensible path forward is to run go install with the -x command-line option and see where the command tries to put the generated executable image, and why this fails (if at all).
You might study the output of go help install and go help build to read more on the subject.
You might also consider forcing usage of Go modules for your particular case:
running GO111MODULES=on go get github.com/linkedin/Burrow would work like five times faster for your use case.
Be sure to study the output of go help modules and go help mod-get first.
bin folder or src folders are not automatically created for you by the go get command. Here are the standard steps creating a new project in go assuming this the first time you are creating a project in go:
Under your workspace directory, create a project directory, say "project1" bin, src directories.
Set GOPATH, GOBIN:
export GOPATH=~/workspace/project1/
export GOBIN=~/workspace/project1/bin
Now if you need just the source code, do a go get github.com/linkedin/Burrow
or if you need a binary do a go install github.com/linkedin/Burrow
The binary will be stored under ~/workspace/project1/bin and source code under ~/workspace/project1/
Same steps would apply either if your creating your project through a make file or terminal
RVM supports .ruby-version and .ruby-gemset on a per project basis and ensures those are set correctly when you navigate to a directory containing those files.
Is there a similar construct I can use for adding directories to my environment PATH variable using RVM?
I haven't found a way to do this using RVM, but I came across another project called direnv that accomplishes exactly what I want.
Here are the steps I took to prepend ./bin to my environment PATH variable on OSX every time I go to my project directory in the shell:
brew install direnv
Add eval "$(direnv hook $0)" to the end of my .zshrc file.
Create a .envrc file in the root of my project with the following content:
PATH_add bin
I'm following this online book in my path to learn Go during the weekends.
I've tried running the go help gopath command it just returns example paths and how they relate to each other in packages and source directories - it's doesn't actually say where I can find the go folder.
The book specifically mentions:
First create a new folder where we can store our program. The
installer you used in chapter 1 created a folder in your home
directory named Go. Create a folder named
~/Go/src/golang-book/chapter2. (Where ~ means your home directory)
From the terminal you can do this by entering the following commands:
I used the default installer on the Go homepage, so assume that everything installed in the default folder the installer comes with.
If I cd in terminal to the ~/ folder and then use ls, there is no /Go folder.
How can I find this folder in order to follow the online book properly? I'm assuming he's using this folder structure for a reason and would rather not deviate and learn how packages work, etc.
The instructions say:
Create a folder named ~/Go/src/golang-book/chapter2
I interpret that to mean that YOU create the folder named "~/Go/src/golang-book/chapter2". The installer doesn't create this, but you can.
E.G. in your Terminal:
mkdir ~/Go
mkdir ~/Go/src
mkdir ~/Go/src/golang-book
mkdir ~/Go/src/golang-book/chapter2