Skip to content

Directory that binary executed from #509

@barslmn

Description

@barslmn

Hi,
System Info:
Debian sid
Doomemacs
rustic version: 3.4

I am using rustic from orgmode by compiling rust code blocks. I have the following files:

❯ ls -1
aoc2022.org
input1

And I have the following code block in the org file:

#+BEGIN_SRC rust :results output
use std::fs;

fn main() {
    let file_path = "input1";
    let contents = fs::read_to_string(file_path)
        .expect("Should have been able to read the file");
}
#+END_SRC

#+RESULTS:
: thread 'main' panicked at 'Should have been able to read the file: Os { code: 2, kind: NotFound, message: "No such file or directory" }', src/main.rs:7:10

Executing this block from org file gives the no such file error. In order to investigate I run the following block:

#+BEGIN_SRC rust 
use std::env;
fn main() {
    println!("{:?}", env::current_dir());
}
#+END_SRC

#+RESULTS:
: Ok("/tmp/babel-C1Nmcb/cargozPIbXS")

My question is how do I change the directory that binary is executed from /tmp/babel-XXXXXX/cargoXXXXXX to where the org file is? This does not happen with other languages (I tried C, python, shell) that's why I think rustic repo is the right place ask.
Thanks, B

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions