Install extension for ALL users running from CLI

Hi.

Apologies if this should be obvious, but I haven’t yet fount the right solution.

Essentially, I have a task runner script that needs to initiate a an object which uses a extension. Precisely: FORGEBOX: cfspreadsheet

So, I’m trying to install the extension so that any user running the task from CommandBox CLI will be able to run the task / use the tag and extension.

I’ve tried:
install 037A27FF-0B80-4CBA-B954BEBD790B460E

and yes it did install and works IF I start server and try a script from my browser from http://127.0.0.1:54536/

That’s all good, but I need it to work from a task runner script which I’m running from CLI. The extension should be available to any users running the task.

I’ve managed to get it working by placing the .lex file found here and saving it in:

C:\Users\jdoe\.CommandBox\engine\cfml\cli\lucee-server\deploy\

But I doubt that’s the “proper” way of doing this, plus that limits the access to the extension only to user jdoe:frowning:

p.s.: I’ve also tried passing in the --system to the install… still didn’t work.

Any help with this would be very much appreciated.

Thanks a million! Pat

@Ravenlost There are several ways to do this, but none of them are fantastic. What I’d REALLY like is for this ticket I entered 5 years ago (!!) to get some love. Please comment and vote:
https://luceeserver.atlassian.net/browse/LDEV-1585

In the mean time, you can do any of the following-- they’re really all about as good/bad as the rest:

  • Copy the lex file to the Lucee engine’s deploy folder for the CLI
  • Specify the LUCEE_EXTENSIONS env var in the environment where box is starting, which Lucee will pick up and process (there’s at least 3 ways of doing this)
  • Run the new Administrator(type,pw).updateExtension(id[,version]) example Micha put in the comments of the ticket above

Well yes, that would happen automatically. It’s not even possible to install an extension such that only some users of the CLi can use it. An extension is either installed or it’s not. And all users of the same CLI installation are using the same Lucee web/server context.

That’s just going to download the lex file and dump it into your current directory (or a Lucee server, if found in that folder), which has nothing to do with the actual Lucee engine powering the CLI.

Nope, it’s as good as any. I agree, it’s sort of lame, but again – I really wish my 5-year-old ticket had been completed a long time ago and I would have built in some functions into Task Runners to ask for extensions to be installed.

I could probably build something using Micha’s hacky workarounds but

  • I’d really rather it be a first class citizen of the language/engine
  • There’s not a lot of demand for this so I don’t think of it that often

Which folder would that be exactly ? The only ones I found were the ones under my user’s profile c:\users\jdoe\.CommandBox\...

OR

You wouldn’t have an working example at hand by any chance ? I’ll just google my way otherwise… I don’t know Lucee so much just like that :wink:

Thanks so much for your time with this, and yeah, I’ll definitely go and see to vote on that ticket you’ve placed 5 yrs ago :wink:

The one you had above looks correct. You can check where the CommandBox home is by running the

info

command and looking at the CommandBox Home line. The Lucee engine that powers the CLI lives in the engine directory inside of that folder.

It depends on a number of things. For example, setting env vars in Windows is not the same as setting them in Linux. Based on your file path above, I’ll assume you’re on Windows. You can set the env var in

  • user variables for your user (under environment variables under system properties)
  • system variables (under environment variables under system properties)
  • with the SET or SETX shell builtin in the cmd terminal before you run box
  • as a Java system property in a command.properties file in the same directory as the box.exe (read automatically by convention)
  • as a Java system property specified as a JVM arg in a box.l4j.ini file in the same directory as the box.exe (read automatically by convention – only works on Windows)

So yeah, lots of options. Lucee will look EITHER for an env var or a java system property.

The first 3 options above are sort of crap. I’d recommend the penultimate one personally. It’s the most self contained and simplest.

So basically, wherever you have your box.exe living, create a commandbox.properties file and put something like this in it:

LUCEE_EXTENSIONS=037A27FF-0B80-4CBA-B954BEBD790B460E

The next time you start box, it will download and install that extension, assuming it finds it in one of the extension providers. To confirm if it worked, check the deploy log in Lucee’s server context somewhere in the neighborhood of C:\Users\jdoe\.CommandBox\engine\cfml\cli\lucee-server\context\logs\deploy.log Or, just run something like this:

CommandBox> #extensionexists 037A27FF-0B80-4CBA-B954BEBD790B460E

or

CommandBox> #extensionlist | printTable id,name,version

I must be doing something wrong, but setting the commandbox.properties as you mentioned and then listing the extensions inside the CLI doesn’t show it. I’ll search some more on this properties or env variables. Really appreciate your help with this one :slight_smile:

Did you restart the CLI? Did you check the deploy log?

Yeah I did. Looking at the deploy.log, I only see an extra line added:

“INFO”,“main”,“03/02/2022”,“15:17:37”,“controller”,“no extension to add/install”

I’m running within C:\CommandBox\box.exe and I 've created the C:\CommandBox\commandbox.properties file with the following content:

LUCEE_EXTENSIONS=037A27FF-0B80-4CBA-B954BEBD790B460E

This is how you meant, correct ?

Yeah, that means Lucee isn’t seeing it. Probably needs to be named differently. I THOUGHT Lucee looked for LUCEE_EXTENSIONS in both env vars and java properties, but maybe it doesn’t. Try this instead

lucee.extensions=037A27FF-0B80-4CBA-B954BEBD790B460E

Funny, I dealt with this back in 2018 and forgot about it

Still not quite working, though getting somewhat better results in the deploy.log:

“INFO”,“main”,“03/02/2022”,“15:38:14”,“controller”,“no extension to add/install”
“INFO”,“main”,“03/02/2022”,“15:38:14”,“controller”,“extensions to install defined in env variable or system property:=037A27FF-0B80-4CBA-B954BEBD790B460E;name=cfspreadsheet;version=3.0.3”
“INFO”,“main”,“03/02/2022”,“15:38:14”,“controller”,“successfully installed extensions :null;=037A27FF-0B80-4CBA-B954BEBD790B460E;name=cfspreadsheet;version=3.0.3”

Doing a

#extensionexists 037A27FF-0B80-4CBA-B954BEBD790B460E

still reveal false after closing/reopening box.exe, and everytime, same new entries in deploy.log :frowning: (when this works, it wont actually re-download the extension every time right?)

Hmm, interesting-- it defo looks like it installed correctly. Did you try using it?

Beats me. You’d have to check the Lucee source. This is one of the many reasons I’m a little salty my 5 year old ticket is just rotting away in the Lucee backlog. Someone did say if you added a specific version to the GUID it wouldn’t download if it was already installed. I haven’t tested it myself.

Yeah I did. No go… :frowning:

Can you show me your exact properties file? I’m curious about the output int he deploy log, it doesn’t quite look right

successfully installed extensions :null;=037A27FF-0B80-4CBA-B954BEBD790B460E;name=cfspreadsheet;version=3.0.3

What’s going on with the :null;= bit?

Also, you should be able to debug the system property from the CLI like so:

env show lucee.extensions

I just tested with

lucee.extensions=037A27FF-0B80-4CBA-B954BEBD790B460E

in my commandbox.properties file. For whatever reason, my deploy log is empty, but

env show lucee.extensions

shows

037A27FF-0B80-4CBA-B954BEBD790B460E

and

#extensionexists 037A27FF-0B80-4CBA-B954BEBD790B460E

outputs true

Oh lord…!!! I am SO sorry!! While I was pasting in all of your requested information, I just noticed a freakin typo in my properties file! I had

lucee.extensions==037… 2 equal signs in there!! Probably when I chaned from LUCEE_… environment variable to the dotnotation one.

Anyways… IT WORKS NOW! :smiley:

CommandBox> #extensionexists 037A27FF-0B80-4CBA-B954BEBD790B460E
true

and my code now seems to be able to go through with :smiley:

You are awesome! Thanks a million for your help!! Have an awesome rest of day :slight_smile:

p.s.: sorry again for the dumb typo I did!

No worries, that’s what I was thinking may have happened. In your defense, this shouldn’t really be such a pain, but we’re sort of working with what we’re dealt :slight_smile: Glad you’ve got yourself going again.