Bash - installing Ocaml-top - bash

I am trying to install Ocaml-Top IDE from command line. I have already installed Ocaml and OPAM using Homebrew (brew install opam, brew install ocaml), but when I enter:
opam install ocaml-top
I get
[ERROR] No OPAM root found at /Users/student/.opam.
Do I need to add this to my PATH?
UPDATE: Suggestion helped, but there is an issue with the package name: I get
[ERROR] No package named ocaml-top found.

You appear to have missed the following caveat, notably opam init, when you ran brew install opam:
$ brew info opam
...
==> Caveats
OPAM uses ~/.opam by default for its package database, so you need to
initialize it first by running (as a normal user):
$ opam init
Run the following to initialize your environment variables:
$ eval `opam config env`
To export the needed variables every time, add them to your dotfiles.
* On Bash, add them to `~/.bash_profile`.
* On Zsh, add them to `~/.zprofile` or `~/.zshrc` instead.
Documentation and tutorials are available at https://opam.ocaml.org, or
via "man opam" and "opam --help".
Bash completion has been installed to:
/usr/local/etc/bash_completion.d
zsh completions have been installed to:
/usr/local/share/zsh/site-functions

Related

kubectl kudo plugin not working after install using brew in linux?

I have installed the kudo plugin on my Linux machine following the instructions in the Kudo CLI page using brew. But it throws error on execution,
user#factotum:~$ kubectl kudo
Error: unknown command "kudo" for "kubectl"
Run 'kubectl --help' for usage.
I tried to list the available plugins, but doesn't have any,
user#factotum:~$ kubectl plugin list
error: unable to find any kubectl plugins
Just installed to reproduce and seems works fine. Have you init it with kubectl kudo init as it mentioned in Install KUDO into your cluster?
My steps(Ubuntu 16.04, 4.15.0-1033-gcp):
$sudo apt install linuxbrew-wrapper
$brew update
$brew vendor-install ruby
$brew update
==> Migrating from Linuxbrew/brew to Homebrew/brew
Linuxbrew/brew has been merged into Homebrew/brew!
Linuxbrew/brew will no longer be updated.
Your git remote has been changed from
https://github.com/Linuxbrew/brew.git
to https://github.com/Homebrew/brew
See the blog post at https://brew.sh/2019/02/02/homebrew-2.0.0/
Already up-to-date.
$brew tap kudobuilder/tap
brew install kudo-cli
==> Downloading https://linuxbrew.bintray.com/bottles-portable-ruby/portable-ruby-2.6.3.x86_64_linux.bottle.tar.gz
######################################################################## 100.0%
....
....
....
....
🍺 /home/bla/.linuxbrew/Cellar/kudo-cli/0.10.1: 5 files, 38.2MB, built in 6 seconds
==> `brew cleanup` has not been run in 30 days, running now...
==> Caveats
==> kubernetes-cli
Bash completion has been installed to:
/home/bla/.linuxbrew/etc/bash_completion.d
$ kubectl kudo init
$KUDO_HOME has been configured at /home/bla/.kudo
✅ installed crds
✅ installed service accounts and other requirements for controller to run
✅ installed kudo controller
Test:
$ kubectl kudo get instances
List of current installed instances in namespace "default":
.
$ kubectl kudo install redis
operator.kudo.dev/v1beta1/redis created
operatorversion.kudo.dev/v1beta1/redis-0.2.0 created
instance.kudo.dev/v1beta1/redis-instance created
$ kubectl plugin list
The following compatible plugins are available:
/home/bla/.linuxbrew/bin/kubectl-kudo
Hope it helps
Can you execute kubectl-kudo? A kubectl plugin is basically just a binary that starts with kubectl-.
So, check where brew installed the kudo binary and check your $PATH.
And you can use kubectl-kudo instead of kubectl kudo if the plugin mechanism doesn't work for some reason.
Did you remember to add the brew environment variables to your shell?
As pr https://brew.sh/ and their install-script https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh you need to add brew to your PATH among others.
OP is tagging bash here so adding this to your shell configuration file.
There will be slight variations based on what shell the user is running, bash, ksh, csh, tcsh.
# At the bottom of .bashrc or .bash_profile
eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)"

Problems using opam and ocaml

I am working on RDP having Ubuntu 14.04 and trying to install ocaml.
I am trying to update my ocaml compiler to 4.05.0 or above but opam switch list gives only one compiler system C system System compiler (4.01.0). Also my opam update gives me below log.
[ERROR] Your version of OPAM (1.1.1) is not recent enough to read ~/.opam/repo/default/repo. Upgrade OPAM to a more recent version (at least 2.0) to read this file correctly.
[ERROR] Skipping https://opam.ocaml.org as the repository is not available.
Updating ~/.opam/repo/compiler-index ...
Updating ~/.opam/compilers/ ...
Updating ~/.opam/repo/package-index ...
Updating ~/.opam/packages/ ...
Updating the cache of metadata (~/.opam/state.cache) ...
Everything is up-to-date.
Any idea how to do this? Thanks for help in advance.
UPDATE:
I need to install newer opam version separately using binary distribution. with this
sh <(curl -sL https://raw.githubusercontent.com/ocaml/opam/master/shell/install.sh)
command I can install it but it will prompt me where to install it,
but I have to automate installation so that there is no interaction from user side. Is there a way to do it?
UPDATE 2:
found a way to do it using ppa see my answer.
Well, as the log says you have to update your OPAM to 2.x. The old version is no longer supported. So you have to follow the installation instructions and update your OCaml.
I tried using sh <(curl -sL https://raw.githubusercontent.com/ocaml/opam/master/shell/install.sh) but failed in doing it as non-interactive script.
I have found this method which does work, though using Ubuntu 14.04 adding ppa sudo add-apt-repository ppa:avsm/ppa and then doing update, upgrade, dist-upgrade and finally installation of opam will be of version 2.2 (latest as by ppa). Follow below commands for exact procedure.
add-apt-repository ppa:avsm/ppa
apt-get update -y
apt-get upgrade -y
apt-get dist-upgrade -y
apt-get install curl build-essential m4 zlib1g-dev libssl-dev ocaml ocaml-native-compilers opam -y
opam init --disable-sandboxing -y
eval `opam config env`
opam update
opam switch list-available
opam switch create 4.07.0
opam init -y
eval `opam config env`
After this Everything should be latest as of now.

Installing ocaml-top on OSX - GTK issue

I am trying to install ocaml-top on macOS High Sierra 10.13. I have installed homebrew (using the command given at https://brew.sh/) and done:
brew install opam
opam init
and answered Y to "Do you want Opam to modify ~/.bash_profile and ~/.ocamlinit". Then:
eval `opam config env`
opam install ocaml-top
I get the following error
The following actions failed
∗ install conf-gtksourceview 2
No changes have been performed
=-=- conf-gtksourceview.2 troobleshooting -=-=-=-=-
=> This package relies on external (system) dependencies that may be
missing.
`opam depext conf-gtksourceview.2' may help you find the correct
installation for your system.
[EDIT: trying on a second mac computer, the error is "[ERROR] The compilation of conf-gtksourceview failed at "pkg-config gtksourceview-2.0"."]
The above depext command gives:
# The following system packages are needed:
# - gtksourceview
# - libxml2
# All required OS packages found.
I have found advice (e.g. https://github.com/OCamlPro/ocaml-top/issues/46) like: "If you installed gtk+ through brew, you may need to do 'export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig' (homebrew)". However typing either that or "export PKG_CONFIG_PATH=/opt/X11/lib/pkgconfig" in the terminal and retrying does not help.
I do not know anything about any of this, but it looked libgtksourceview2.0-dev might be involved, so I tried
opam install libgtksourceview2.0-dev
but
[ERROR] No package named libgtksourceview2 found.
Likewise "brew install libgtksourceview2.0-dev" or "brew install libgtksourceview".
https://github.com/ocaml/opam-repository/issues/8449 seems to imply this error could be because other packages need to be upgraded, and mentions that "the expanded pkg-config --short-errors --print-errors "gtksourceview-2.0 >= 2.2.0" [...] does print more information". I have no idea what this means though and how to detect which packages need to be upgraded.
You could try
brew install pkg-config gtksourceview libxml2
Otherwise, running brew search <part-of-name-of-dep> may help to find the required dependencies.

Installing Z3 with OCaml bindings

I'm trying to install Z3 with OCaml bindings and getting the following error.
cp ../src/api/ml/z3.mli api/ml/z3.mli
ocamlc -I api/ml -o api/ml/z3.cmi -c api/ml/z3.mli
File "api/ml/z3.mli", line 1159, characters 35-50:
Error: Unbound module Big_int
make: *** [api/ml/z3.cmo] Error 2
I firstly tried installing via
opam install z3
And then I tried cloning the Z3 repo and running
python scripts/mk_make.py --ml
cd build
make
After which I get the same error.
Any help would be greatly appreciated. Thank you!
The Z3 installation is expecting an older OCaml environment. In recent OCaml releases, Big_int is in the Num module.
$ opam install num
For what it's worth, I don't believe there is an OPAM module for Z3. If you run the Z3 install, the OCaml/Z3 interface gets installed as if it was an OPAM module (in ~/.opam). But it's not really.
I'm using Z3 every day, so I can verify that it works (both OCaml 4.03.0 and OCaml 4.06.0.)
Update
I just now verified that there is a Z3 package in OPAM these days, and I was able to install it under OCaml 4.06.0 on a previously clean system that I happen to have handy. The system is Ubuntu 14.04.
I needed to do the following initial installations:
sudo apt-get update
sudo apt-get install ocaml
sudo apt-get install m4
sudo apt-get install dev-libgmp
sudo apt-get install g++
Then I installed OPAM:
sudo add-apt-repository ppa:avsm/ppa
sudo apt-get update
sudo apt-get install opam
Now running as myself:
$ opam init
$ eval `opam config env`
$ opam update
$ opam switch 4.06.0
$ eval `opam config env`
$ opam install z3
$ ls ~/.opam/4.06.0/lib/z3
dllz3ml.so z3.cmi z3enums.cmx z3ml.cmxa z3native.cmx
libz3ml.a z3.cmo z3enums.mli z3ml.cmxs z3native.mli
libz3.so z3.cmx z3enums.o z3.mli z3native.o
META z3enums.cmi z3ml.a z3native.cmi z3native_stubs.o
opam.config z3enums.cmo z3ml.cma z3native.cmo z3.o
This looks good to me. I'm not a Z3 wizard; it's mostly just a dependency of a project I'm working on. But these are the files I'm used to seeing.

The command rbenv install is missing

In Ubuntu 10.04 I just installed rbenv.
The install command is not present.
rbenv 0.4.0-49-g8b04303
Usage: rbenv <command> [<args>]
Some useful rbenv commands are:
commands List all available rbenv commands
local Set or show the local application-specific Ruby version
global Set or show the global Ruby version
shell Set or show the shell-specific Ruby version
rehash Rehash rbenv shims (run this after installing executables)
version Show the current Ruby version and its origin
versions List all Ruby versions available to rbenv
which Display the full path to an executable
whence List all Ruby versions that contain the given executable
See `rbenv help <command>' for information on a specific command.
For full documentation, see: https://github.com/sstephenson/rbenv#readme
What am I missing?
The install command is not embedded into rbenv, it comes from the ruby-build plugin. You can install it using the command:
git clone https://github.com/rbenv/ruby-build.git "$(rbenv root)"/plugins/ruby-build
On Mac OS X you can install it through homebrew:
brew install ruby-build
On Debian (version >= 7) and Ubuntu (version >= 12.10) both rbenv and ruby-build can be installed using apt-get (or aptitude):
sudo apt-get update
sudo apt-get install rbenv ruby-build
On FreeBSD ruby-build is available in the Ports Collection, it can be install both as a binary package or build from the port:
# Using pkgng rbenv will be installed
pkg install ruby-build
# Building ruby-build form Ports will install rbenv only if the RBENV option is set
cd /usr/ports/devel/ruby-build
make install
I found that when using rbenv from a global directory, it's necessary to export the RBENV_ROOT variable, otherwise it won't load the plugins.
export RBENV_ROOT="/usr/local/rbenv"
if [ -d "${RBENV_ROOT}" ]; then
export PATH="${RBENV_ROOT}/bin:${PATH}"
fi
As everyone mentioned problem is missing ruby-build. For older versions of OS ruby-build may not be available as an apt package. In that case install using original instructions, which should've omitted the word Optional in this:
(Optional) Install ruby-build, which provides the rbenv install
command that simplifies the process of installing new Ruby versions.
git clone git#github.com:rbenv/ruby-build.git ~/.rbenv/plugins/ruby-build
# OR use http
git clone https://github.com/rbenv/ruby-build.git ~/.rbenv/plugins/ruby-build
Simply install ruby-build in ubuntu:
sudo apt-get install ruby-build
And add
eval "$(rbenv init -)"
To your ~/.bashrc
I had installed the ruby-build plugin before and installed ruby 1.9.3-p327 using
$ rbenv install 1.9.3-p327
A few days later I tried to install ruby 2.0.0-p247 using
$ rbenv install 2.0.0-p247
but I received the error message
rbenv: no such command 'install'
All I had to do was to run
$ exec $SHELL -l
and that fixed the problem.
Answered on 2021
If you're getting that error, it's very likely you have accidentally skipped one of the installation instructions:
git clone https://github.com/rbenv/ruby-build.git ~/.rbenv/plugins/ruby-build
echo 'export PATH="$HOME/.rbenv/plugins/ruby-build/bin:$PATH"' >> ~/.bashrc
exec $SHELL
Replace .bashrc with whatever shell you're using, for example .zshrc, or just manually access your shell config file and paste this line:
export PATH="$HOME/.rbenv/plugins/ruby-build/bin:$PATH"
I strong advise against re-installing/installing Ruby via brew or apt-get just to get around this issue. The whole point of using rbenv is to make your life easier in future when there is ruby version upgrade, or when you're working on different rails projects that require different version of ruby.
It looks like ruby-build is not present. Run this command :
git clone https://github.com/rbenv/ruby-build.git "$(rbenv root)"/plugins/ruby-build
Anyone finding their way here with this issue on OSX and already having installed ruby-build via homebrew (like me), you may solve this by just upgrading ruby-build:
brew update
brew upgrade ruby-build
This fixed the problem for me.
This issue also happens in Linux when doing a stand-alone installation of ruby-build, if the ruby-build executable is not found in the path. If installing under /usr/local, try for example:
PATH=/usr/local/bin:$PATH /usr/local/bin/rbenv install ...
I came to this solution, but looking for a macOS solution that uses MacPorts.
So, here the same command using MacPorts:
➜ ~ sudo port install ruby-build
Password:
---> Computing dependencies for ruby-build
---> Fetching archive for ruby-build
---> Attempting to fetch ruby-build-20210804_0.darwin_19.noarch.tbz2 from https://packages.macports.org/ruby-build
---> Attempting to fetch ruby-build-20210804_0.darwin_19.noarch.tbz2.rmd160 from https://packages.macports.org/ruby-build
---> Installing ruby-build #20210804_0
---> Activating ruby-build #20210804_0
---> Cleaning ruby-build
---> Scanning binaries for linking errors
---> No broken files found.
---> No broken ports found.
➜ ~ curl -fsSL https://github.com/rbenv/rbenv-installer/raw/main/bin/rbenv-doctor | bash
Checking for `rbenv' in PATH: /opt/local/bin/rbenv
Checking for rbenv shims in PATH: OK
Checking `rbenv install' support: /opt/local/bin/rbenv-install (ruby-build 20210804)
Counting installed Ruby versions: none
There aren't any Ruby versions installed under `/Users/user/.rbenv/versions'.
You can install Ruby versions like so: rbenv install 3.0.2
Checking RubyGems settings: OK
Auditing installed plugins: OK
➜ ~ rbenv install 3.0.2
Downloading openssl-1.1.1k.tar.gz...
-> https://dqw8nmjcqpjn7.cloudfront.net/892a0875b9872acd04a9fde79b1f943075d5ea162415de3047c327df33fbaee5
Installing openssl-1.1.1k...

Resources