Nixpkgs: Arduino: binaries installed through Boards Manager fail to run

Created on 23 Nov 2019  路  8Comments  路  Source: NixOS/nixpkgs

Describe the bug
Binaries installed through the Boards Manager in Arduino IDE
fail to run due to missing shared libraries.

A solution to this is to patchelf them manually after installation.

To Reproduce
Steps to reproduce the behavior:

  1. Tools > Boards > Boards Manager
  2. install Arduino SAM Boards
  3. Verify/Compile

Expected behavior
Code is compiled using the installed binaries

Metadata
Please run nix run nixpkgs.nix-info -c nix-info -m and paste the result.

  • system: "x86_64-linux"
  • host os: Linux 4.19.80, NixOS, 19.03.173660.3f92c2124a5 (Koi)
  • multi-user?: yes
  • sandbox: yes
  • version: nix-env (Nix) 2.2
  • channels(root): "nixos-19.03.173660.3f92c2124a5, nixos-unstable-20.03pre201791.c1966522d7d"
  • nixpkgs: /nix/var/nix/profiles/per-user/root/channels/nixos

Maintainer information:

# a list of nixpkgs attributes affected by the problem
attribute:
# a list of nixos modules affected by the problem
module:
bug stale

Most helpful comment

I have a simple package that puts arduino in an FHSEnv. It could probably be adapted into something in-tree eventually

with import <nixpkgs> { };
let
  unwrappedArduino = pkgs.arduino;
  in buildFHSUserEnv {
    name = "arduino";
    passthru = { inherit (unwrappedArduino) pname version meta; };
    targetPkgs = pkgs: with pkgs; [
      unwrappedArduino
      zlib
      (python3.withPackages (p: with p; [ pyserial ]))
    ];
    extraInstallCommands = ''
      mkdir -p $out/share/applications
      cp ${unwrappedArduino}/share/applications/arduino.desktop $out/share/applications/arduino.desktop
      substituteInPlace $out/share/applications/arduino.desktop \
          --replace ${unwrappedArduino}/bin/arduino $out/bin/arduino
    '';
    runScript = "arduino";
  }

All 8 comments

@tg-x Which package provides "Arduino IDE"?

arduino-1.8.5

I see that we have an extra commit on master that is not on release-19.09: https://github.com/NixOS/nixpkgs/commit/4c85abae94b0a55ff76387c1f1793370a170dda8#diff-556d00d6117d82c7a9b1845340d48283
@tg-x Could you try arduino-1.8.9 from master?

cc @antono @auntie @robberer @bjornfor @bergey

same issue with arduino-1.8.9 from master

@tg-x For documentation purposes, could you, please, post the error messages and manual patchelf commands that fix it for you.

for the Arduino AVR Boards package it looks like this:

> ~/.arduino15/packages/arduino/tools/avr-gcc/7.3.0-atmel3.6.1-arduino5/bin/avr-gcc                                                                                                                                              
zsh: no such file or directory: ~/.arduino15/packages/arduino/tools/avr-gcc/7.3.0-atmel3.6.1-arduino5/bin/avr-gcc
> ldd ~/.arduino15/packages/arduino/tools/avr-gcc/7.3.0-atmel3.6.1-arduino5/bin/avr-gcc                                                                                                                                          
        linux-vdso.so.1 (0x00007ffe11fb4000)                                                                                                                                                                                      
        libm.so.6 => /nix/store/h0p0h3rh1q4i2yavzm3yqi716s9yaj2f-glibc-2.27/lib/libm.so.6 (0x00007f145d6f4000)                                                                                                                    
        libc.so.6 => /nix/store/h0p0h3rh1q4i2yavzm3yqi716s9yaj2f-glibc-2.27/lib/libc.so.6 (0x00007f145d53e000)                                                                                                                    
        /lib64/ld-linux-x86-64.so.2 => /nix/store/h0p0h3rh1q4i2yavzm3yqi716s9yaj2f-glibc-2.27/lib64/ld-linux-x86-64.so.2 (0x00007f145d88c000)

then running patchelf --set-interpreter for all the binaries fixes this:

for bin in ~/.arduino15/packages/arduino/tools/avr-gcc/7.3.0-atmel3.6.1-arduino5/avr/bin/* ~/.arduino15/packages/arduino/tools/avr-gcc/7.3.0-atmel3.6.1-arduino5/avr/bin/*; do
  ld=$(ldd $bin | awk '/ld-linux/{print $3}')
  if [ "$ld" -ne "" ]; then patchelf --set-interpreter "$ld" "$bin"; fi
done

I have a simple package that puts arduino in an FHSEnv. It could probably be adapted into something in-tree eventually

with import <nixpkgs> { };
let
  unwrappedArduino = pkgs.arduino;
  in buildFHSUserEnv {
    name = "arduino";
    passthru = { inherit (unwrappedArduino) pname version meta; };
    targetPkgs = pkgs: with pkgs; [
      unwrappedArduino
      zlib
      (python3.withPackages (p: with p; [ pyserial ]))
    ];
    extraInstallCommands = ''
      mkdir -p $out/share/applications
      cp ${unwrappedArduino}/share/applications/arduino.desktop $out/share/applications/arduino.desktop
      substituteInPlace $out/share/applications/arduino.desktop \
          --replace ${unwrappedArduino}/bin/arduino $out/bin/arduino
    '';
    runScript = "arduino";
  }

Hello, I'm a bot and I thank you in the name of the community for opening this issue.

To help our human contributors focus on the most-relevant reports, I check up on old issues to see if they're still relevant. This issue has had no activity for 180 days, and so I marked it as stale, but you can rest assured it will never be closed by a non-human.

The community would appreciate your effort in checking if the issue is still valid. If it isn't, please close it.

If the issue persists, and you'd like to remove the stale label, you simply need to leave a comment. Your comment can be as simple as "still important to me". If you'd like it to get more attention, you can ask for help by searching for maintainers and people that previously touched related code and @ mention them in a comment. You can use Git blame or GitHub's web interface on the relevant files to find them.

Lastly, you can always ask for help at our Discourse Forum or at #nixos' IRC channel.

Was this page helpful?
0 / 5 - 0 ratings