Snap and autotools plugin

Hi,

I am trying to create a snap from R-language version 4 (https://cran.r-project.org/src/base/R-4/R-4.0.2.tar.gz). The R install directory can be set during the config phase with “–prefix PATH”. The installation will hard code the given path and the program expects itself to be run from the given path. So, basically R is installed with

./configure --prefix=TARGET_PATH
make
make install

How these types of programs are snapped?

It looks like the R install needs to install directly to the final target path ($SNAP), but this does not work with snapcraft as the build seems to fail with error message: “Failed to generate snap metadata: The specified command ‘bin/R’ defined in the app ‘R’ is not executable.”

Thanks

Can you share your YAML?

Perhaps it should be usr/bin/R?

If using core20, you can configure the prefix using something like:

parts:
  hello:
    plugin: autotools
    source: .
    autotools-configure-parameters:
    - --prefix=/usr

Maybe check whether the in-build-environment /root/prime/bin/R file has executable permission?

Yes, this I can do and have tried, but after that R expects itself to be run from /usr/bin/R folder, but snap seems to place files to under /snap. So, running R will end up R trying to fetch files from /usr, but it does not find them.

There is no bin/R, but it is in /root/prime/snap/snapcraft/5472/bin/R.

I suppose you’ve wrongly referenced $SNAP in the build recipe, note that the environment variable only has proper value during the runtime of the snap application.

Set installation prefix to /snap/$SNAPCRAFT_PROJECT_NAME/current instead, refer Environment variables that Snapcraft exposes for more details.

Makes sense. I did try to modify my yaml, but got the same error message. Perhaps now my apps command is wrong, but it does not seem to allow any variables.

Here is my latest yaml.
http://node.dy.fi/files/snapcraft.yaml

What might be wrong in this yaml?

apps:
  R:
    environment:
      LC_ALL: en_US.UTF-8
      LANG: en_US.UTF-8 

Should use C.UTF-8 locale as it is the only locale supported by the snap runtime.


parts:
  r:
    override-build: |
      snapcraftctl build

Unnecessary scriptlet (probably leftover, though)


parts:
  r:
#    organize:
#      snap/r-base/usr: usr

Try the following(example):

    organize:
      snap/$SNAPCRAFT_PROJECT_NAME/current: /

parts:
  r:
    stage-packages:
      - libtcl8.6
      - libtk8.6

The tcltk-launch launcher: Fix Tcl/Tk applications in the snap runtime may help.

1 Like

Thank you! It works now!! Organize solved the biggest issue, I think. For now, I just removed the tcl/tk packages.

2 Likes