FORUM CTRLX AUTOMATION
ctrlX World Partner Apps for ctrlX AUTOMATION
Dear Community User! We have started the migration process.
This community is now in READ ONLY mode.
Read more: Important
information on the platform change.
12-12-2023 07:14 AM
I am building snap with node version 16.17.0 it works fine. but when I change the node version to 18.17.0 and build the snap app I got following issue.
+ tar xzf - -C /home/boschrexroth/projects/mairotech/parts/mariotech/install/ --no-same-owner --strip-components=1
+ npm config set unsafe-perm true
npm ERR! `unsafe-perm` is not a valid npm option
npm ERR! A complete log of this run can be found in: /home/boschrexroth/.npm/_logs/2023-12-12T05_57_41_208Z-debug-0.log
Failed to build 'mariotech'.
Recommended resolution:
Check the build logs and ensure the part's configuration and sources are correct.
and this is my snapcraft.yaml file
12-12-2023 08:45 AM - edited 12-12-2023 09:29 AM
There were incompatible changes in the used nodejs. We are using the latest version node 20. This was fixed in our SDK version 2.04.0. See code below:
override-build: |
# detect target arch
if [ $SNAPCRAFT_TARGET_ARCH == "arm64" ]; then
target_arch="arm64"
else
target_arch="x64"
fi
# detect build arch
if [ $SNAP_ARCH == "arm64" ]; then
build_arch="arm64"
else
build_arch="x64"
fi
# fetch node for target arch to be packed
if [ ! -f "${SNAPCRAFT_PART_INSTALL}/bin/node" ]; then
node_path="${SNAPCRAFT_PART_INSTALL}/bin"
node_uri=https://nodejs.org/dist/v${NODE_VERSION}/node-v${NODE_VERSION}-linux-${target_arch}.tar.gz
echo fetching node for install: $node_uri
curl $node_uri | tar xzf - -C $SNAPCRAFT_PART_INSTALL --no-same-owner --strip-components=1
fi
# fetch node used for build (if not equal to target arch for cross build)
if [ $build_arch != $target_arch ]; then
node_path=$SNAPCRAFT_PART_BUILD/bin
if [ ! -f "${SNAPCRAFT_PART_BUILD}/bin/node" ]; then
node_uri=https://nodejs.org/dist/v${NODE_VERSION}/node-v${NODE_VERSION}-linux-${build_arch}.tar.gz
echo fetching node for build: $node_uri
curl $node_uri | tar xzf - -C $SNAPCRAFT_PART_BUILD --no-same-owner --strip-components=1
fi
fi
# set the path to build target node to be used for build
echo node path: $node_path
export PATH=$node_path:$PATH
node --version
npm --version
# install and compile (tsc -> ./dist)
npm install --ignore-scripts --no-fund --unsafe-perm
npm run tsc
# pack and install the app (only production)
npm install -g --prefix $SNAPCRAFT_PART_INSTALL $(npm pack . | tail -1) --ignore-scripts --omit=dev --no-fund --unsafe-perm
# remove ctrlx-datalayer prebuilds of unused archs to reduce snap size
package_name=$(npm run getName -s)
prebuilds_location="${SNAPCRAFT_PART_INSTALL}/lib/node_modules/${package_name}/node_modules/ctrlx-datalayer/prebuilds"
if [ -d "$prebuilds_location" ]; then
find $prebuilds_location -type f -not -ipath "*/linux-${target_arch}*" -delete
fi
# remove unused binaries
rm -rf ${SNAPCRAFT_PART_INSTALL}/bin/npm
rm -rf ${SNAPCRAFT_PART_INSTALL}/bin/npx
rm -rf ${SNAPCRAFT_PART_INSTALL}/bin/corepack
# remove unused node modules
rm -rf ${SNAPCRAFT_PART_INSTALL}/lib/node_modules/npm
rm -rf ${SNAPCRAFT_PART_INSTALL}/lib/node_modules/corepack
12-12-2023 11:07 AM
I have changed the node version to 20.9.0 and got this issue while building snap app
Note: I am using js not ts
Building mariotech
+ snapcraftctl build
+ '[' '!' -f /home/boschrexroth/projects/mairotech/parts/mariotech/install/bin/node ']'
+ curl -s https://nodejs.org/dist/v20.9.0/node-v20.9.0-linux-x64.tar.gz
+ tar xzf - -C /home/boschrexroth/projects/mairotech/parts/mariotech/install/ --no-same-owner --strip-components=1
gzip: stdin: unexpected end of file
tar: Unexpected EOF in archive
tar: Unexpected EOF in archive
tar: Error is not recoverable: exiting now
Failed to build 'mariotech'.
Recommended resolution:
Check the build logs and ensure the part's configuration and sources are correct.
* The terminal process "/bin/bash '-c', 'bash build-snap-amd64.sh'" terminated with exit code: 2.
12-12-2023 11:09 AM
I made above changes in my snapcraft.yaml file and got this issue now:
+ snapcraftctl build
+ cp --archive --link --no-dereference . /home/boschrexroth/projects/mairotech/parts/configs/install
Building mariotech
+ snapcraftctl build
+ '[' '!' -f /home/boschrexroth/projects/mairotech/parts/mariotech/install/bin/node ']'
+ curl -s https://nodejs.org/dist/v20.9.0/node-v20.9.0-linux-x64.tar.gz
+ tar xzf - -C /home/boschrexroth/projects/mairotech/parts/mariotech/install/ --no-same-owner --strip-components=1
+ npm config set unsafe-perm true
npm ERR! `unsafe-perm` is not a valid npm option
npm ERR! A complete log of this run can be found in: /home/boschrexroth/.npm/_logs/2023-12-12T10_08_13_242Z-debug-0.log
Failed to build 'mariotech'.
Recommended resolution:
Check the build logs and ensure the part's configuration and sources are correct.
* The terminal process "/bin/bash '-c', 'bash build-snap-amd64.sh'" terminated with exit code: 2.
* Terminal will be reused by tasks, press any key to close it.
12-13-2023 10:25 AM
In version Node 20 LTS the option "--unsafe-perm" is not longer available to you need to remove it from your snapcraft.yaml.
Or use the Node 18 LTS (sudo npm install node --channel=18/stable).
12-13-2023 10:45 AM
I have upgraded the node version to 20.9.0,but getting this error now.
Note: I have removed unsafe-perm from snapcraft.yaml file
+ tar xzf - -C /home/boschrexroth/projects/mairotech/parts/mariotech/install/ --no-same-owner --strip-components=1
+ npm config set unsafe-perm true
npm ERR! `unsafe-perm` is not a valid npm option
npm ERR! A complete log of this run can be found in: /home/boschrexroth/.npm/_logs/2023-12-13T09_40_58_467Z-debug-0.log
Failed to build 'mariotech'.
Recommended resolution:
Check the build logs and ensure the part's configuration and sources are correct.
* The terminal process "/bin/bash '-c', 'bash build-snap-amd64.sh'" terminated with exit code: 2.
* Terminal will be reused by tasks, press any key to close it.
12-15-2023 08:51 AM
It seem the "unsafe-perm" option is still present in your snapcrat.yaml. Could you share it so we can have a look to it? Feel free to send it to me via private message if it should be visible in the forum.
12-15-2023 11:56 AM
here is my snapcraft.yaml
12-20-2023 11:33 AM
Hi @jawad
We are currently working on a solution for this issue and will publish a patch for the SDK including a bugfix in the new year.
Best regards and happy holidays!
12-21-2023 06:57 AM
OK
Thanks @nickH
i will be waiting
06-05-2024 02:48 PM
Hi @jawad
sorry for coming back so late. With the V2.6 SDK this issue seems to be fixed. Can you try out as well?
I just tried with the sample: samples-node/datalayer.provider.alldata from the SDK and was able to build the snap successfully. But be carefull the build can take some time.
Best regards,
Nick
09-18-2024 08:10 AM
@jawad Are there any news? Could this issue been solved.