Thanks for the help. I don’t see what you’re doing differently.
I got this layout:
.
├── Gemfile
├── Gemfile.lock
└── snap
├── plugins
│ ├── myruby.py
│ └── __pycache__
│ └── myruby.cpython-36.pyc
└── snapcraft.yaml
3 directories, 5 files
And this is my snapcraft.yaml file:
name: test-my-ruby-plugin
base: core20
version: '0.1.0'
summary: Test my ruby plugin
description: |
Foo bar
grade: devel
confinement: devmode # use 'strict' once you have the right plugs and slots
parts:
my-snap-test:
plugin: myruby
#use-bundler: true
source: .
apps:
my-snap-test:
command: bin/hello-world
And my plugin file:
"""
This ruby plugin is useful for building ruby based parts.
"""
from textwrap import dedent
from typing import Any, Dict, List, Set
from snapcraft.plugins.v2 import PluginV2
class MyrubyPlugin(PluginV2):
@classmethod
def get_schema(cls) -> Dict[str, Any]:
return {
"$schema": "http://json-schema.org/draft-04/schema#",
"type": "object",
"additionalProperties": False,
"properties": {
"ruby-version": {
"type": "string",
"default": "3.0.1",
"pattern": r"^\d+\.\d+(\.\d+)?$",
},
"use-bundler": {
"type": "boolean",
"default": False,
},
},
"required": ["source"],
}
def __init__(self, *, part_name: str, options) -> None:
super().__init__()
self._ruby_version = options.ruby_version
feature_pattern = re.compile(r"^(\d+\.\d+)\..*$")
self._feature_version = feature_pattern.sub(r"\1", self._ruby_version)
def get_build_snaps(self) -> Set[str]:
return set()
def get_build_packages(self) -> Set[str]:
return {"gcc", "make", "zlib1g-dev", "libssl-dev", "libreadline-dev"}
def get_build_environment(self) -> Dict[str, str]:
#return {"PATH": "${HOME}/.cargo/bin:${PATH}"}
return {}
def _get_download_command(self) -> str:
url = "https://cache.ruby-lang.org/pub/ruby/{}/ruby-{}.tar.gz".format(
self._feature_version, self._ruby_version
)
# if ! [ -f "${{HOME}}/ruby.tar.gz" ]; then
# curl --proto '=https' --tlsv1.2 -sSf {url} > ${{HOME}}/ruby.tar.gz
# fi
return dedent(
f"""\
pwd
"""
)
def _get_install_command(self) -> str:
#cmd = ["make", '-j"${SNAPCRAFT_PARALLEL_BUILD_COUNT}"']
# cmd = [
# 'echo "parallel_build_count: ${SNAPCRAFT_PARALLEL_BUILD_COUNT}"',
# 'pwd',
# ]
# if self.options.use_bundler:
# logger.info("Using bundler")
# # cmd.extend(
# # ["--features", "'{}'".format(" ".join(self.options.rust_features))]
# # )
# return " ".join(cmd)
return 'echo "my install command"'
def get_build_commands(self) -> List[str]:
return [self._get_command_command(), self._get_install_command()]
I just reinstalled snapcraft and multipass completely (multipass couldn’t determine the IP of the instance anymore). I’m still getting this error:
[...]
Setting up netplan.io (0.101-0ubuntu3~20.04.2) ...
Setting up snapd (2.48.3+20.04) ...
Installing new version of config file /etc/apparmor.d/usr.lib.snapd.snap-confine.real ...
snapd.failure.service is a disabled or a static unit, not starting it.
snapd.snap-repair.service is a disabled or a static unit, not starting it.
Setting up systemd-sysv (245.4-4ubuntu3.6) ...
Setting up cloud-init (20.4.1-0ubuntu1~20.04.1) ...
Installing new version of config file /etc/cloud/cloud.cfg ...
Processing triggers for mime-support (3.64ubuntu1) ...
Processing triggers for libc-bin (2.31-0ubuntu9.2) ...
Processing triggers for dbus (1.12.16-2ubuntu2.1) ...
Processing triggers for linux-image-5.4.0-71-generic (5.4.0-71.79) ...
/etc/kernel/postinst.d/initramfs-tools:
update-initramfs: Generating /boot/initrd.img-5.4.0-71-generic
W: Couldn't identify type of root file system for fsck hook
/etc/kernel/postinst.d/zz-update-grub:
Sourcing file `/etc/default/grub'
Sourcing file `/etc/default/grub.d/40-force-partuuid.cfg'
Sourcing file `/etc/default/grub.d/init-select.cfg'
Generating grub configuration file ...
Found linux image: /boot/vmlinuz-5.4.0-71-generic
Found initrd image: /boot/initrd.img-5.4.0-71-generic
Found linux image: /boot/vmlinuz-5.4.0-53-generic
Found initrd image: /boot/initrd.img-5.4.0-53-generic
done
Processing triggers for ca-certificates (20210119~20.04.1) ...
Updating certificates in /etc/ssl/certs...
0 added, 0 removed; done.
Running hooks in /etc/ca-certificates/update.d...
done.
Processing triggers for initramfs-tools (0.136ubuntu6.4) ...
update-initramfs: Generating /boot/initrd.img-5.4.0-71-generic
W: Couldn't identify type of root file system for fsck hook
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following NEW packages will be installed:
apt-transport-https
0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
Need to get 1,704 B of archives.
After this operation, 161 kB of additional disk space will be used.
Get:1 http://archive.ubuntu.com/ubuntu focal-updates/universe amd64 apt-transport-https all 2.0.5 [1,704 B]
Fetched 1,704 B in 0s (14.8 kB/s)
debconf: delaying package configuration, since apt-utils is not installed
Selecting previously unselected package apt-transport-https.
(Reading database ... 20219 files and directories currently installed.)
Preparing to unpack .../apt-transport-https_2.0.5_all.deb ...
Unpacking apt-transport-https (2.0.5) ...
Setting up apt-transport-https (2.0.5) ...
2021-04-15T15:59:16+02:00 INFO Waiting for automatic snapd restart...
snapd 2.49.2 from Canonical✓ installed
core20 20210319 from Canonical✓ installed
core18 20210309 from Canonical✓ installed
"core18" switched to the "latest/stable" channel
snapcraft 4.6.2 from Canonical✓ installed
"snapcraft" switched to the "latest/stable/ubuntu-20.04" channel
Loaded local plugin for myruby
Failed to load plugin: unknown plugin: 'myruby'