# R script from bin folder isn't executed

**URL:** <https://community.seqera.io/t/r-script-from-bin-folder-isnt-executed/771>\
**Category:** Ask for help\
**Created:** [May 20, 2024, 9:38pm UTC](https://community.seqera.io/t/r-script-from-bin-folder-isnt-executed/771 "2024-05-20T21:38:25Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![complexgenome](https://dub1.discourse-cdn.com/flex013/user_avatar/community.seqera.io/complexgenome/32/392_2.png) [@complexgenome](https://community.seqera.io/u/complexgenome)\
**Post date:** [May 20, 2024, 9:38pm UTC](https://community.seqera.io/t/r-script-from-bin-folder-isnt-executed/771/1 "2024-05-20T21:38:25Z")

</div>

Hi there,  
I’ve a bin folder under which I’ve put few scripts (bash and R).

The bash script is picked and executed with no issues. However, the R script isn’t executed.

My nextflow script is as:

```auto
"""
echo $genes_samples"\n"
Rscript nflow_long_to_wide_mut.R

"""

```

I get error as:

```auto
  Fatal error: cannot open file 'nflow_long_to_wide_mut.R': No such file or directory

```

It’s header as:

```auto
#!/usr/bin/env Rscript

```

Let me know if any other details are needed.

---

<div class="post-metadata">

**Author:** ![mribeirodantas](https://dub1.discourse-cdn.com/flex013/user_avatar/community.seqera.io/mribeirodantas/32/235_2.png) [@mribeirodantas](https://community.seqera.io/u/mribeirodantas)\
**Post date:** [May 21, 2024, 1:03pm UTC](https://community.seqera.io/t/r-script-from-bin-folder-isnt-executed/771/2 "2024-05-21T13:03:44Z")

</div>

Hey @complexgenome

The magic behind the project `bin` folder is that Nextflow will add it to `$PATH`, so that when you run a program that is there, the operating system will know where the program is. When you run `Rscript`, `Rscript` would be this program, not the argument (R script filename). What you’re doing is almost right! 🙂 You have the shebang already (`#!/usr/bin/env Rscript`) so you just have to call your script in the Nextflow pipeline.

```auto
"""
echo $genes_samples"\n"
nflow_long_to_wide_mut.R
"""

```

Make sure it has execution permission (`chmod +r`).

Could you try this please?

---

<div class="post-metadata">

**Author:** ![complexgenome](https://dub1.discourse-cdn.com/flex013/user_avatar/community.seqera.io/complexgenome/32/392_2.png) [@complexgenome](https://community.seqera.io/u/complexgenome)\
**Post date:** [May 21, 2024, 8:50pm UTC](https://community.seqera.io/t/r-script-from-bin-folder-isnt-executed/771/3 "2024-05-21T20:50:15Z")

</div>

@mribeirodantas  
I did try that, please see below error:

```auto
Command error:
  .command.sh: line 2: ./nflow_long_to_wide_mut.R: No such file or directory

```

I have executed chmod +r to the script and it is also chmod +x.

Then, I removed the `./` then it worked. I used nflow\_long\_to\_wide\_mut.R without any ./ or Rscript.

Thank you

---

<div class="post-metadata">

**Author:** ![mribeirodantas](https://dub1.discourse-cdn.com/flex013/user_avatar/community.seqera.io/mribeirodantas/32/235_2.png) [@mribeirodantas](https://community.seqera.io/u/mribeirodantas)\
**Post date:** [May 21, 2024, 8:56pm UTC](https://community.seqera.io/t/r-script-from-bin-folder-isnt-executed/771/4 "2024-05-21T20:56:47Z")

</div>

Oh, sorry. You’re right, there’s no need to have the `./`. Thanks for pointing this out! I just updated the answer 😉

---

<div class="post-metadata">

**Author:** ![system](https://dub1.discourse-cdn.com/flex013/user_avatar/community.seqera.io/system/32/2402_2.png) [@system](https://community.seqera.io/u/system)\
**Post date:** [May 28, 2024, 8:57pm UTC](https://community.seqera.io/t/r-script-from-bin-folder-isnt-executed/771/5 "2024-05-28T20:57:33Z")

</div>

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.
