I have created a brew formulae for one of my github repos. Now I want run 2 bash scripts that are present in the project.
My formulae looks likes this :
class UnifaiCore < Formula
##branch_name = "brew-installer"
desc ""
homepage "homepage_url"
url "project_url",
:branch => ##branch_name
version "v0.1.0"
license ""
def install()
puts "inside install"
puts %x(whoami)
venv_setup_script = "unifai-core-venv-setup.sh"
installer_script = "unifai-core-installer.sh"
bin.install venv_setup_script
exec("#{prefix}/bin/#{venv_setup_script}")
bin.install installer_script
exec("#{prefix}/bin/#{installer_script}")
# I have also tried system, %x() to run these bash scripts, have also tried adding source in front.
end
end
Now when ever I am trying to run this using brew install command. I am getting permission denied error.
Error: An exception occurred within a child process:
Errno::EACCES: Permission denied - /usr/local/Cellar/unifai-core/v0.1.0/bin/unifai-core-venv-setup.sh
I have tried following things till now :
How to fix homebrew permissions?
giving chmod 775 to the folder
I also checked which user it's using to execute the scripts but printing whoami. It's the same user that I have used to run these bash scripts in my terminal.
Related
I've created a python tool and want to install it via brew. Creating the formula worked fine at first when i simply had one python file named myTool. Then i seperated the code into more files as it became larger and more complex.
How do i set up the install to bundle those files, because right now the imports are failing because the other files are not found.
My current install
def install
bin.install 'myTool'
end
The error shown when running the brew installed tool
from myModule import someFunc, someOtherFunc ModuleNotFoundError: No module named 'myModule'
The current setup only installs the angler file without any of the other python modules. This results in the ModuleNotFoundError error. Here is my suggestion:
def install
# Determines the python version being used
# e.g. If python3.10, xy = 3.10
xy = Language::Python.major_minor_version "python3"
# Where to install the python files
packages = libexec/"lib/python#{xy}/site-packages/angler"
# For each file present, install them in the right location
%w[angler anglerEnums.py anglerGen.py anglerHelperFunctions.py].each do |file|
packages.install file
end
# Create a symlink to the angler python file
bin.install_symlink packages/"angler"
end
From the docs it seems like using Serverspec to verify that packages are installed should be pretty straight-forward, but I'm having some interesting problems with vim and ag (the_silver_searcher).
I am using Test Kitchen with the kitchen-vagrant plugin and have two platforms: ubuntu-1404 and centos-72. All of my specs pass for Ubuntu, and two of them fail for Centos: vim and ag.
vim
The Chef code that handles this installation is super simple:
package "vim"
And here is the spec:
describe "Vim" do
describe package("vim") do
it { should be_installed }
end
end
Again, very straight-forward. However, it fails on my Centos build with this error:
2) Vim Package "vim" should be installed
Failure/Error: it { should be_installed }
expected Package "vim" to be installed
/bin/sh -c rpm\ -q\ vim
package vim is not installed
Yet if I login to the server, it most definitely is installed:
▶ kitchen login all-centos-72
Last login: Sat Jul 2 17:53:30 2016 from 10.0.2.2
[vagrant#all-centos-72 ~]$ vim --version
VIM - Vi IMproved 7.4 (2013 Aug 10, compiled Jun 10 2014 06:55:55)
[vagrant#all-centos-72 ~]$ which vim
/usr/bin/vim
[vagrant#all-centos-72 ~]$ sudo yum install -y vim
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* base: distro.ibiblio.org
* extras: mirror.us.leaseweb.net
* updates: mirror.eboundhost.com
Package 2:vim-enhanced-7.4.160-1.el7.x86_64 already installed and latest version
Nothing to do
ag
ag is more complicated in that the installation requires building from source on Centos whereas on Ubuntu it's available with apt-get. Here is the relevant part of the recipe:
bash "install Development Tools" do
code "yum -y groupinstall \"Development Tools\""
end
package %w(pcre-devel xz-devel)
target_dir = File.join("/", "usr", "local", "the_silver_searcher")
git "clone the ag repo" do
repo "https://github.com/ggreer/the_silver_searcher/"
revision "master"
destination target_dir
end
bash "install ag" do
not_if system("hash ag")
cwd target_dir
code <<-EOF
./build.sh
make install
EOF
end
And here is the spec:
describe "The Silver Searcher" do
if host_inventory["platform"] == "ubuntu"
describe package("silversearcher-ag") do
it { should be_installed }
end
else
describe package("the_silver_searcher") do
it { should be_installed }
end
end
end
The Centos failure:
1) The Silver Searcher Package "the_silver_searcher" should be installed
Failure/Error: it { should be_installed }
expected Package "the_silver_searcher" to be installed
/bin/sh -c rpm\ -q\ the_silver_searcher
package the_silver_searcher is not installed
Likewise, if I log into the Centos VM I can use ag:
[vagrant#all-centos-72 ~]$ ag --version
ag version 0.32.0
[vagrant#all-centos-72 ~]$ which ag
/usr/local/bin/ag
These commands also work if I switch to root user.
I've tried to cheat the system by writing my specs in different ways for the Centos platform:
describe command("ag") do
its(:stderr) { should match /Usage: ag/ }
end
The above also doesn't work, even though typing ag when logged in (exit status 1) does produce that usage content. My last attempt was:
describe file("/usr/local/bin/ag") do
it { should exist }
end
This works but feels super hacky and like it shouldn't be necessary.
Anyone have recommendations here? Is there something I'm missing/doing wrong with these packages? I initially thought that the ag problem was only because it was installed from source rather than a package manager, but vim was installed with a package manager and still has the same problem as ag.
The answer to the question has two parts, one dealing with the way Serverspec works and the other with how various Linux distributions handle packages.
1) Serverspec users shouldn't assume any behavior that isn't literally implied by the name of the package resource. Applications that are installed by any means other than the system's package manager will not be picked up and their successful installation should be tested by other means. This could include, as in the question, testing for the existence of a binary file.
2) When the developer has installed an application with a package manager, he/she must be aware that package managers on different Linux distributions sometimes (often?) have different names for the same package. A classic example of this is apache2 on Debian systems vs. httpd on RedHat systems. In the specific case mentioned in the question, vim is recognized on CentOS as vim-enhanced even though yum accepts vim as the name when installing it (thanks to #matt-schuchard for pointing out that they are linked).
Also wanted to credit #Karen B for helping me reach these conclusions in the comments to the question.
You aren't installing ag via a package so it's not a "hack" for that to not work.
I am trying to install Theano for machine learning on my Windows 7 computer.
One of the last steps in installing the dependencies is to 'create a link library for GCC' by 'Opening up the Python shell and cd to C:\SciSoft. Then execute:
gendef WinPython-64bit-2.7.9.4\python-2.7.9.amd64\python27.dll
dlltool --dllname python27.dll --def python27.def --output-lib WinPython-
64bit-2.7.9.4\python-2.7.9.amd64\libs\libpython27.a
I've tried doing this but I get a invalid syntax error highlighted on 'WinPython'. I tried changing directory to go deeper and running gendef again and it also returned the same error. This is a copy and paste job from http://deeplearning.net/software/theano/install_windows.html#install-windows
I also followed the tutorial at the link to install Theano.
The line "Finally we need to create a link library for GCC. Open up the Python shell and cd to c:\SciSoft" is probably an error; "the Python shell" should be modified to "cmd.exe".
The two-line scripts are not python scripts, and can be successfully run on cmd.exe after changing directory to c:\SciSoft.
I have a Mac Book Pro, it has Perl.
I have a script with includes.
use LWP ;
use HTTP::Request::Common qw{ POST };
use HTML::Form;
LWP so I ran (twice once as root once as normal user) Guide I followed
perl -MCPAN -e 'shell'
install Bundle::LWP
install HTML::Tree
install HTML::Form
Warning: Cannot install HTML::Format, don't know what it is.
It says its missing two dependencies, but when I install them it says they are already done...?
Pastebin showing the output of the dependencies problem
When I run the script this is the error I get:
Can't locate LWP.pm in #INC (#INC contains: /opt/local/lib/perl5/site_perl/5.16.3/darwin-thread-multi-2level /opt/local/lib/perl5/site_perl/5.16.3 /opt/local/lib/perl5/vendor_perl/5.16.3/darwin-thread-multi-2level /opt/local/lib/perl5/vendor_perl/5.16.3 /opt/local/lib/perl5/5.16.3/darwin-thread-multi-2level /opt/local/lib/perl5/5.16.3 /opt/local/lib/perl5/site_perl /opt/local/lib/perl5/vendor_perl .) at NMLRegAttack2.pl line 1.
BEGIN failed--compilation aborted at NMLRegAttack2.pl line 1.
build_dir_reuse is not set correctly
Solution
cpan
conf build_dir_reuse 0
o conf commit
exit
So I have a local DMG that I'm installing with puppet (VirtualBox-4.2.18-88780-OSX.dmg), and I run it with
sudo puppet resource package virtualbox ensure=present provider=pkgdmg source=puppet:///virtualbox/VirtualBox-4.2.18-88780-OSX.dmg,
and everything works fine. But when I try to remove it with sudo puppet resource package virtualbox ensure=absent, I get an error
Error: Could not set 'absent' on ensure: undefined method 'uninstall' for #<Puppet::Type::Package::ProviderPkgdmg:0x107cb8218>
I have a vague idea of why this is happening, it doesn't look like puppet is recognizing the virtualbox uninstall tool. How do I fix this?
millmouse is correct OS X packages can't be uninstalled, at least by this method. Puppet doesn't support 'absent' on appdmg or apppkg providers.
You can however trick Puppet to reinstall a package by removing the 'cookie' like file it creates to track the package was installed. Puppet creates a file in /var/db with a pattern like .puppet_<provider>_installed_<package_name>-<version> on OS X; for example you'll have a file like /var/db/.puppet_pkgdmg_installed_VirtualBox-4.2.18-88780
You could do something like the following, but it won't actually uninstall the app only trick Puppet into allowing it to be installed again:
exec {'rm -f .puppet_pkgdmg_installed_VirtualBox-4.2.18-88780':
cwd => /var/db/',
user => 'root',
onlyif => 'test -f /var/db/.puppet_pkgdmg_installed_VirtualBox-4.2.18-88780',
}
or
file {'/var/db/.puppet_pkgdmg_installed_VirtualBox-4.2.18-88780':
ensure => 'absent',
force => true,
}
Otherwise the version number or name of the package needs to change in order to install again.
I would use an exec resource to do the uninstall rather than the package resource.
exec { "uninstall_mypkg" :
command => "uninstall mypkg",
onlyif => "check if the package is installed",
path => "/path/to/command/",
}