# Mender-artifact with single-file

**URL:** <https://hub.mender.io/t/mender-artifact-with-single-file/6984>\
**Category:** Update Modules\
**Tags:** mender-artifact\
**Created:** [July 3, 2024, 1:35am UTC](https://hub.mender.io/t/mender-artifact-with-single-file/6984 "2024-07-03T01:35:26Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![samfrliu](https://yyz2.discourse-cdn.com/flex036/user_avatar/hub.mender.io/samfrliu/32/2219_2.png) [@samfrliu](https://hub.mender.io/u/samfrliu)\
**Post date:** [July 3, 2024, 1:35am UTC](https://hub.mender.io/t/mender-artifact-with-single-file/6984/1 "2024-07-03T01:35:26Z")

</div>

I tried to update a file by using mender-artifact (single-file-artifact-gen works fine)  
but I got a error message bellow

> info: Running Mender client 4.0.3  
> info: Deployment with ID 3f5c7979-1a4b-4a47-887f-4f5c7d0a0a0d started.  
> info: Sending status update to server  
> info: Installing artifact…  
> info: Sending status update to server  
> info: Update Module output (stderr): cat: {…}  
> info: Update Module output (stderr): /var/lib/mender/modules/v3/payloads/0000/tree/files/dest\_dir{…}  
> info: Update Module output (stderr): : No such file or directory{…}  
> info: Update Module output (stderr):  
> error: Process returned non-zero exit status: ArtifactInstall: Process exited with status 1  
> info: Update Module output (stderr): cat: {…}  
> info: Update Module output (stderr): /var/lib/mender/modules/v3/payloads/0000/tree/files/filename{…}  
> info: Update Module output (stderr): : No such file or directory{…}  
> info: Update Module output (stderr):  
> error: Process returned non-zero exit status: ArtifactRollback: Process exited with status 1  
> info: Sending status update to server

I’m using command bellow, any suggestions would be greatly appreciated

> mender-artifact write module-image   
> -n myservice-update-1   
> -t ubuntu   
> -T single-file   
> -f my\_file.txt   
> -o myservice-update-1.mender

---

<div class="post-metadata">

**Author:** ![TheYoctoJester](https://yyz2.discourse-cdn.com/flex036/user_avatar/hub.mender.io/theyoctojester/32/1444_2.png) [@TheYoctoJester](https://hub.mender.io/u/TheYoctoJester)\
**Post date:** [July 3, 2024, 7:48am UTC](https://hub.mender.io/t/mender-artifact-with-single-file/6984/2 "2024-07-03T07:48:36Z")

</div>

Hi @samfrliu,

Your invocation of `mender-artifact` does create an artifact which has the `single-file` type, but misses a number of the things that `single-file-artifact-gen` does. If you look at [mender/support/modules-artifact-gen/single-file-artifact-gen at 793909fbcde154c93509060058b55e3d1b4cb31f · mendersoftware/mender · GitHub](https://github.com/mendersoftware/mender/blob/793909fbcde154c93509060058b55e3d1b4cb31f/support/modules-artifact-gen/single-file-artifact-gen#L211) and the following lines, it is not just the payload file that you need to transport, but also additional files that hold the metadata(permissions, paths, and so on). Hence it is advisable to either use the provided script which handles all of it as required, or make sure that you actually replicate all necessary parts.

Greets,  
Josef

---

<div class="post-metadata">

**Author:** ![samfrliu](https://yyz2.discourse-cdn.com/flex036/user_avatar/hub.mender.io/samfrliu/32/2219_2.png) [@samfrliu](https://hub.mender.io/u/samfrliu)\
**Post date:** [July 3, 2024, 10:59am UTC](https://hub.mender.io/t/mender-artifact-with-single-file/6984/3 "2024-07-03T10:59:59Z")

</div>

Thanks for the reply, but I don’t really understand…  
I want update “/home/ubuntu/my\_file.txt” on my ubuntu  
Could you please give me a sample for my purpose?

---

<div class="post-metadata">

**Author:** ![TheYoctoJester](https://yyz2.discourse-cdn.com/flex036/user_avatar/hub.mender.io/theyoctojester/32/1444_2.png) [@TheYoctoJester](https://hub.mender.io/u/TheYoctoJester)\
**Post date:** [July 4, 2024, 8:08am UTC](https://hub.mender.io/t/mender-artifact-with-single-file/6984/4 "2024-07-04T08:08:39Z")

</div>

@samfrliu the easiest way is to just use the web UI:

 ![Screenshot 2024-07-04 at 10.03.31](https://canada1.discourse-cdn.com/flex036/uploads/mender/original/2X/6/6fd6777c91501c4a8bbae82e562e4297da774ef6.png)  
If you upload the file there, then you can provide the path, for example `/home/ubuntu/my_file.txt`, and the matching artifact will be automatically generated.

For doing it on the command line, please use the `single-file-artifact-gen` script. Example:

```auto
single-file-artifact-gen my_file.txt \
  --dest-dir "/home/ubuntu" \
  --artifact-name my-file-1.0 \
  --output-path my-file-1.0.mender \
  --device-type $WHATEVERYOURDEVICETYPEIS

```

Greets,  
Josef

---

<div class="post-metadata">

**Author:** ![samfrliu](https://yyz2.discourse-cdn.com/flex036/user_avatar/hub.mender.io/samfrliu/32/2219_2.png) [@samfrliu](https://hub.mender.io/u/samfrliu)\
**Post date:** [July 4, 2024, 10:02am UTC](https://hub.mender.io/t/mender-artifact-with-single-file/6984/5 "2024-07-04T10:02:10Z")

</div>

Thanks for the reply, I know “single-file-artifact-gen” can work fine, but if I want add a script & signature, it must be “mender-artifact”, right?  
Or mender-artifact can not be used on single-file?

---

<div class="post-metadata">

**Author:** ![TheYoctoJester](https://yyz2.discourse-cdn.com/flex036/user_avatar/hub.mender.io/theyoctojester/32/1444_2.png) [@TheYoctoJester](https://hub.mender.io/u/TheYoctoJester)\
**Post date:** [July 4, 2024, 10:16am UTC](https://hub.mender.io/t/mender-artifact-with-single-file/6984/6 "2024-07-04T10:16:10Z")

</div>

@samfrliu no, `single-file-artifact-gen` ist just a script that calls `mender-artifact` internally too. If you want to add special parameters like for signing, you can pass them after `--`, like

```auto
single-file-artifact-gen my_file.txt \
  --dest-dir "/home/ubuntu" \
  --artifact-name my-file-1.0 \
  --output-path my-file-1.0.mender \
  --device-type $WHATEVERYOURDEVICETYPEIS
  -- \
  -k $YOURKEYFILE

```

I strongly suggest to look at the `single-file-artifact-gen` script, it has a long help and explanation section right at the top.

Greets,  
Josef

---

<div class="post-metadata">

**Author:** ![samfrliu](https://yyz2.discourse-cdn.com/flex036/user_avatar/hub.mender.io/samfrliu/32/2219_2.png) [@samfrliu](https://hub.mender.io/u/samfrliu)\
**Post date:** [July 8, 2024, 1:46am UTC](https://hub.mender.io/t/mender-artifact-with-single-file/6984/7 "2024-07-08T01:46:08Z")

</div>

I figure out how to set parameter  
thanks for your great help
