8

TL;DR

How to create system wide alias to snap package in Ubuntu 16.04?

More details

I would like to install Blender as a snap. I found, that there is blender-tpaw package which can be installed. Unfortunately after installing it, it is available in terminal under name blender-tpaw, not blender.

Using snap alias

So first of all I've tried to run command sudo snap alias blender-tpaw blender, according to: https://insights.ubuntu.com/2017/01/28/ubuntu-core-how-to-enable-aliases-for-your-snaps-commands/. But this is what I've got:

error: cannot perform the following tasks:
- Enable aliases for snap "blender-tpaw" (cannot enable alias "blender" for "blender-tpaw", no such alias)

Create symbolic link in /usr/local/bin

Then I've tried to make symbolic link sudo ln -s /snap/bin/blender-tpaw /usr/local/bin/blender but in this case very strange thing happen: now when I type blender in a terminal I've got output of snap command...

Put alias in /etc/profile.d

I've also tried to create alias in /etc/profile.d/alias.sh

alias blender='blender-tpaw'

But this work only, on my Ubuntu 16.04 Server, but doesn't work in Ubuntu 16.04 Desktop.

What I want to achieve?

I want that this alias will be system wide, for all users, without changing manually .bashrc for each user separately. And I want the same way working on Ubuntu Server, and Ubuntu Desktop as well.

  • Maybe this helps? insights.ubuntu.com/2017/01/28/… – edwinksl May 14 '17 at 12:01
  • @edwinksl I use command from this article, but it seems that it not possible to declare your own aliases without rebuilding whole snap. – Piotr Ciążyński May 14 '17 at 12:05
  • Ah I see. I don't really use snaps, so I am of no help here, but I hope there is a simple solution to this; rebuilding snaps just to make aliases is overkill. – edwinksl May 14 '17 at 12:11
  • After you make the symlink to /usr/local/bin/blender, what is the output from entering the command blender? Also, do you have anything else in your path named blender (use type -a blender to list everything the shell has hashed under that name)? – takatakatek Jun 13 '17 at 20:09
1

Whatever problem was encountered last year when trying to register the alias now seems fixed. The same sequence worked on 16.04, and the nearly released 18.04 as well. Versions uses are in the output.

$ sudo snap install blender-tpaw
[sudo] password for dpb: 
blender-tpaw 2.78c-tpaw0 from 'tpaw' installed
$ sudo snap alias blender-tpaw blender
Added:
  - blender-tpaw as blender
$ sudo snap aliases
Command                  Alias         Notes
aws-cli.aws              aws           -
blender-tpaw             blender       manual
conjure-up.conjure-down  conjure-down  -
lxd.lxc                  lxc           -
$ snap version
snap    2.32.3.2+18.04
snapd   2.32.3.2+18.04
series  16
ubuntu  18.04
kernel  4.15.0-15-generic

References:

0

To set up an alias outside snap using the bash-builtin alias function you need to call snap explicitly, so in your case the command is:

alias blender='snap run blender-tpaw'

man bash says:

When an interactive shell that is not a login shell is started, bash reads and executes commands from /etc/bash.bashrc and ~/.bashrc, if these files exist.

So to make the alias available system wide, just add it to the /etc/bash.bashrc file:

echo "alias blender='snap run blender-tpaw'" >> /etc/bash.bashrc

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.