Homebrew on Linux - brew install not seeing existing packages - homebrew

I'm using Home Brew on my system to allow users to install some packages; there are some that are installed at the system level (e.g. build-essential) but when I run a formula brew is not able to see them and download them. Is this the expected behavior or is there something I can do to fix this?

It's an expected behavior. Homebrew on Linux, namely Linuxbrew, uses its own libraries.
Homebrew does not use any libraries provided by your host system, except glibc and gcc if they are new enough. Homebrew can install its own current versions of glibc and gcc for older distributions of Linux.
References
Homebrew documentation of Linuxbrew

Related

How to setup ROS environment variable on Ubuntu 20.04?

I tried following this guide to install ROS, but even after adding ROS source.list and its key
sudo apt install ros-melodic-desktop-full
gave error.
E: Unable to locate package ros-melodic-desktop-full
Then I ran this command
sudo apt search ros
to see if any such package exists. I couldn't find ros-melodic-desktop-full but I found another similar package ros-desktop-full.
So I installed it instead. The installation went smooth without giving any errors.
Next step in the guide is to set-up ROS environment variable, but I have no such directory
/opt/ros
So how do I setup the environment variable?
P.S.
I also installed some tools and dependencies with this command
sudo apt install python3-rosdep python3-rosinstall python3-rosinstall-generator python3-wstool build-essential
and initialized rosdep
sudo rosdep init
rosdep update
The ros-desktop-full package you installed is part of the official Ubuntu release.
ROS Melodic (and in the future, Noetic) is published by the OSRF in a separate repository (packages.ros.org). These packages install to /opt/ros/. However, some ROS packages have also been ported to Debian, which is how they found their way to Ubuntu (which derives from Debian).
The Debian packages are fully functional, but they do not install to /opt/ros. Instead, everything is integrated in the operating system itself. This means that you need to set up your personal workspace slightly differently.
Given that most tutorials assume that you use the OSRF packages, I suggest you either wait for the Noetic release (scheduled for the end of May 2020), then install ros-noetic-desktop-full, or downgrade to Ubuntu 18.04 LTS to use ROS Melodic.
From the documentation here, melodic is only supported on Ubuntu 18.04. The ROS version targeting Focal (20.04) is Noetic, but that one has not been released yet (see Distributions). I'm not sure what ROS version Ubuntu packages (the ros-desktop-full one you installed), but I was not successful in using it.
If you really do want to use Ubuntu 20.04, then I think your best option currently is to compile from source. Last time I checked the precompiled debs for Noetic are not yet available at http://packages.ros.org/ros/ubuntu (you can track release progress at github issue 21513). No idea if compiling Noetic from source is easy or hard, but I was able to compile ROS2 foxy from source without too much trouble though.

luarocks lyaml installation error

on luarocks install lyaml I get following error:
Error: Could not find expected file libyaml.a, or libyaml.so, or libyaml.so.* for YAML -- you may have to install YAML in your system and/or pass YAML_DIR or YAML_LIBDIR to the luarocks command. Example: luarocks install lyaml YAML_DIR=/usr/local
lua version: 5.1.5
How do I install YAML in system to start using lyaml rock?
Whenever you get a LuaRocks message saying you may have to install ____ in your system it means the rockspec has an external dependency.
Installing external dependencies
The way to satisfy this dependency is to install the package using the appropriate means of your system: if using Debian/Ubuntu, with apt-get, if using macOS, probably using Homebrew, etc.
Note that for building code, in systems that have the concept of dev packages, such as most Linux distributions, you need to install both the main library package and the dev package (which contains the header files for compilation). For example, for Debian/Ubuntu, to satisfy this dependency you need to run apt-get install libyaml libyaml-dev.
Unfortunately, the names are not fully consistent across systems and distros: a module may be called ncurses-dev in one system, libncurses6w-dev in another, etc. So in your particular case you'll have to search around for the right name of the YAML library (the package providing libyaml) in your system.
Once the external dependency is installed...
Installing a library with the system package manager will usually install the necessary files in locations that are automatically detected by LuaRocks, so running
luarocks install lyaml
again should find the libyaml files and proceed with the installation.
If external dependencies are installed in a non-standard location
If that fails, you can find the directories where the library (libyaml.so) and header (yaml.h) were installed and tell LuaRocks about it. For example, if libyaml.so was installed in some non-standard locations such as /opt/lib/yaml/libyaml.so and the header in /opt/include/yaml-1/yaml.h you would do this:
luarocks install lyaml YAML_LIBDIR=/opt/lib/yaml/ YAML_INCDIR=/opt/include/yaml-1/
This kind of situation happens when a system installs headers or libraries in a subdirectory. For example, for LuaSec on the Mac, which uses OpenSSL, it is sometimes necessary to use pathnames like this:
luarocks install luasec OPENSSL_INCDIR=/usr/local/opt/openssl/include OPENSSL_LIBDIR=/usr/local/opt/openssl/lib

What is the difference between brew install X and brew cask install X

I'm familiarizing myself with the whole homebrew kit and the documentation is rather poor.
What is a cask, Cellar and a tap?
Homebrew-Cask is an extension to Homebrew to install GUI applications such as Google Chrome or Atom. It started independently but its maintainers now work closely with Homebrew’s core team.
Homebrew calls its package definition files “formulae” (British plural for “formula”). Homebrew-Cask calls them “casks”. A cask, just like a formula, is a file written in a Ruby-based DSL that describes how to install something.
The Cellar is where Homebrew installs things. Its default path is /usr/local/Cellar (/opt/homebrew/Cellar on Apple Silicon). It then add symlinks from standard locations to it.
For example, when you type brew install git:
Homebrew installs it under /usr/local/Cellar/git/<version>/, with the git binary in /usr/local/Cellar/git/<version>/bin/git
It adds a symlink from /usr/local/bin/git to that binary
This allows Homebrew to keep track of what’s installed by Homebrew versus software installed by other means.
A tap is a source of formulae. The default is homebrew/core but you can add more of them. The simplest way to create a formula for your own software is to create a GitHub repository called homebrew-<something>; put your formula file in it; then type brew tap <username>/<something> to add this new source of formulae to your Homebrew installation and so get access to all its formulae.
Some companies have internal Homebrew taps for their own utilities. There are a lot of public taps like atlassian/tap for Atlassian software, or ska-sa/tap for radio astronomy. Homebrew itself used to have additional taps like homebrew/science but they deprecated them and imported the formulæ in homebrew/core.
I personally differentiate brew & cask just based on 1 of the main (if not the only main) differences, of graphical GUI applications being managed by cask rather than just brew. (There are other differences too which I don't know as much about).
Below adapted from 'Graham Miln' on apple.stackexchange:
Homebrew
brew is the core command for the Homebrew project.
The missing package manager for OS X
Homebrew installs the stuff you need that Apple didn’t.
Homebrew typically deals with command line software (not graphical GUI applications). Most of the software is distributed under an open source licence.
Cask
brew cask is an extension to brew that allows management of graphical GUI applications.
Homebrew Cask extends Homebrew and brings its elegance, simplicity,
and speed to OS X applications and large binaries alike.
Cask deals with a mixture of software and licences.
Cask offers a way to command line manage the installation of graphical GUI applications.
Licensing
Availability through brew or cask does not imply any specific licence.
Quoting from official docs:
Cask
https://github.com/Homebrew/homebrew-cask
Homebrew Cask extends Homebrew and brings its elegance, simplicity,
and speed to the installation and management of GUI macOS applications
such as Atom and Google Chrome.
Cellar
https://docs.brew.sh/Formula-Cookbook
Homebrew installs to the Cellar and then symlinks some of the
installation into /usr/local so that other programs can see what’s
going on.
Tap
https://docs.brew.sh/Taps
Taps (Third-Party Repositories)
brew tap adds more repositories to the
list of formulae that brew tracks, updates, and installs from. By
default, tap assumes that the repositories come from GitHub, but the
command isn’t limited to any one location.
Update on command:
The current version of homebrew deprecated the "brew cask" syntax. From now on, se the --cask modifier instead.
brew --cask

Uninstall MacPorts

I want to switch to Homebrew instead of MacPorts because Homebrew told me to (http://cl.ly/image/1b0M0q2x1C3K) and it seems better.
I'm a bit weary about how to uninstall MacPorts since it's installed trough Terminal and not trough .app as a regular OS X program.
How do I uninstall?
sudo port -f uninstall installed
will uninstall all ports.
Then read the guide for cleaning up the leftover bits.
https://guide.macports.org/chunked/installing.macports.uninstalling.html
You can use brew along with macports without any issues as brew installs the packages under a different directory.
I have been using both of these package managers without any problems.
Macports and Brew are better in their own way, you never know when you might want to use macports, it is going to get better and faster.
I tend to use both depending on what I want to install and do further.
If you still insist on uninstalling MacPorts, you can follow the steps as mentioned by Kirk Roybal.
I know this is an old post.
But for clarity: brew installs to /usr/local. macports installs to /opt/local. When you have duplicates (binaries, objects, libraries) and/or version difference (i.e. duplicates that have the same name but are different versions), then you can have issues if you do not manage it. Manage it through your command search rules (PATH in bash,csh for example) and your library search rules if applicable. If you have a collision that can't be resolved this way or you don't want to deal with it, then you have to pick one - i.e. delete the one you don't want and replace it with a link to the one to keep. I've used both MacPorts and Brew for a long time successfully.

Homebrew version of macports `port select --set`

One of the reasons I'm still using macports is that it is easy to switch between versions of things you download. For example, if I want to change my GCC version to 4.8 all I have to do is
sudo port set --select gcc mp-gcc48
No mucking around in environmental variables. I see that there are multiple versions of gcc to be got from homebrew, but is there an easy way to activate and deactivate versions of things? I didn't notice anything in the documentation.
Option 1 is that you install multiple versioned packages in parallel. Then you'd call gcc-4.7 or gcc-4.8, etc.
Option 2 is to selectively brew link and brew unlink the package versions that you prefer to use. Note that an "unlinked" package is still installed and usable from /usr/local/opt/<package>/, it's just not in the default path.
Which one you use depends on how the individual packages are set up and how often you need to switch around. It's perhaps not quite as clear-cut as with MacPorts, but it works just fine.

Resources