Installed Ruff in CodeRunner: but uh, a bit stuck how to use it!

Re: Installed Ruff in CodeRunner: but uh, a bit stuck how to use it!

by Richard Lobb -
Number of replies: 2

Yes, it seems that ruff isn't installed in any of the directories in the PATH variable.

Chris's first message referred to ruff being installed in "our instance of CodeRunner (we know it's installed)". That raised a doubt in my mind as to whether ruff was installed on the Moodle server (which wouldn't work) or the Jobe server (which is what's required).

If ruff is definitely installed on the Jobe server, then I would assume it's not in a directory on the PATH.

When I was testing ruff, I first installed it with the command given on the ruff web page: "curl -LsSf https://astral.sh/ruff/install.sh | sh". But that installs in a a directory <home>/.cargo/bin, which won't be searched by Jobe as it has cleaned the PATH variable for security. I instead installed it using pip (as root) with the --break-system-packages command line option. I'd be a bit hesitant to do on a production server, but it worked fine on my development server, putting ruff at /usr/local/bin/ruff. It was then usable from CodeRunner.

Perhaps the first thing to try is to change your script to try executing /root/.cargo/bin/ruff rather than just ruff. It that doesn't work, talk to whoever installed ruff on jobe to find out where it landed up! You may be able to execute it by giving its full path to the subprocess run command, or you could ask the sysadmin to link to it from one of the standard executable directories, like /usr/local/bin. 

In reply to Richard Lobb

Re: Installed Ruff in CodeRunner: but uh, a bit stuck how to use it!

by Chris Nelson -
Hi,

Apologies, I meant that IT team installed it on to the JOBE server, with the files being confirmed as installed to /usr/local/bin/ruff

Having told Oli the directory, he seems to be having some joy running Python with Ruff when specifying the location in his question - hopefully he'll be able to better explain once he's had some time exploring. As this is outside of our usual area, the IT Servers colleague and I are unsure if there's a misconfiguration, we've failed to find some needed documentation, or if there's a bug somewhere.
In reply to Chris Nelson

Re: Installed Ruff in CodeRunner: but uh, a bit stuck how to use it!

by Oli Howson -
Yes as suspected it was a path issue - calling by /path/to/ruff it works fine.

worth noting for future issues:
1) You can drop a ruff.toml cofig file in the support files no problem - very useful
2) Using Richard's method is better than mine:

with open("__student_answer__.py", "w") as outfile:
outfile.write(__student_answer__)
subprocess.run("ruff check -q __student_answer__.py".split())

Otherwise it picks up on all our naughty code in the tester as well :)

so a win!