Euphoria Ticket #592: eu.cfg files processed in wrong order

I put an eu.cfg file in my tests directory, but my /.eu.cfg file is taking precedence over it. The proper order for looking / processing eu.cfg files should be:

  • Command line switches
  • Directory of main program file
  • Current working directory
  • Directory of executable
  • Standard OS specific locations

In particular, my goal was to make it easy to run tests using my development version of the std library. Putting an eu.cfg in that directory should be enough, but my "normal" eu.cfg, which points to the installed std library was taking precedence, causing me to run with the wrong set of include files.


Type: Bug Report Severity: Major Category: Front End
Assigned To: mattlewis Status: Fixed Reported Release:
Fixed in SVN #: View VCS: none Milestone: 4.0.1

1. Comment by SDPringle Jan 11, 2011

I don't agree that this should be a bug report but I do think the order in which the eu.cfg are processed should be thought about again. When talking about order the first one in the precedence is the last one to be processed. Now, presently once some items are set you cannot set them again. For example the backend switch. You may set the backend switch in one cfg file and then you'll get an error if it comes in the other or even the command line.

2. Comment by DerekParnell Jan 11, 2011

Regardless of the eu.cfg file processing order, it seems to me that we also need to rethink the 'switch' functionality.

The issue is what to do when a commandline switch is repeated on a line. I see that we have a number of options, each of which are valid.

  • the last one is used.
  • the first one is used
  • the new one is appended to a list
  • the new one is prepended to a list

Also I think we need to have the ability to remove a previous switch. So for example if the command line has -b- then because it ends in a dash it means remove any previous -b switch.

3. Comment by jeremy Jan 13, 2011


Have you tried and tested this? We went through extra work in the backend to make sure that duplicate flags that were flagged as "ONCE" did not cause an error. Before sending to the cmd_parse, only the last man standing is sent. So, if you have 5 -eudir settings in various configs along the parsing path, only the last one works.

If you tested and it's failing, then that is another bug that needs to be filed.


4. Comment by mattlewis Jan 13, 2011

I think it should be the first encountered config that works (in theory, once we process them in the correct order). Based on what I originally wrote in the ticket description:

  1. Command line switch should clearly take precedence...the user just told us what he wants
  2. A config in the directory of the main program file should be considered to be applied specifically to the program in question, and is presumably meant to override specific system settings. For instance, maybe the program needs a special version of some library, or something else that's odd.
  3. Current working directory: this is where the user is. I'm not totally sure that reading this automatically makes sense. In many cases, it will be the same as the dir of the program being run, and should be loaded that way. Otherwise, if the user wants it, perhaps he should put it on the command line.
  4. Executable / Standard locations: These are "generic" system wide specifications good for general operations, and should apply if the more specific configs don't.

5. Comment by jeremy Jan 13, 2011

Actually, I forget which one stands. I know the command line overrides the config files, but I do think it is currently programmed as the last man standing. All that can be flipped of course.

6. Comment by DerekParnell Feb 20, 2011

From my understanding of how Euphoria currently works, it builds a virtual command line from data coming from various eu.cfg files and the actual (user's) command line, then processes that virtual command line's switches. So in effect the virtual command line looks like ...

[switches from eu.cfg in std locns] 
[switches from eu.cfg in exe dir] 
[switches from eu.cfg in pwd] 
[switches from eu.cfg in main prog] 
[switches from original cmdline] 
These switches are then processed in that order.

Which means that any "-I" switches from the original command line get searched last.

Have I got this right?

7. Comment by mattlewis Feb 22, 2011

No, include paths supplied on the command line are not searched last. In general, they will be searched before any paths in "automatic" config files. Paths coming from config files that appear before the -i switch will be read before the path in the -i switch.

This issue is definitely a bug, and the order is clearly incorrect based on user intention, since the user can only override a system wide config file (e.g., in the users home directory) with an explicit -c switch.

Placing a config file in the executable's directory, or in the program's directory is a pretty obvious sign of user intent, and should be honored. The problem appears pretty simple, actually. Essentially, the order in which we look for eu.cfg files in pathopen:GetDefaultArgs looks in the platform-specific locations before the current working directory or the executable path.

One situation in which this fix will be extremely helpful is for developers. Consider that we can put a eu.cfg file in the build directory (created, presumably, by the configure script) that will ensure that the development standard library is used. This eliminates the need to always specify with an -i switch. It will also be useful for having multiple versions of euphoria installed.

To confirm the order in which paths are searched, examine the contents of the result from include_paths(0).

8. Comment by mattlewis Feb 22, 2011

See: hg:euphoria/rev/18349bb87b1c

changeset: 4662:18349bb87b1c branch: 4.0 user: Matt Lewis date: Tue Feb 22 10:02:15 2011 -0500 files: source/pathopen.e description:

  • eu.cfg files in application directory applied first
  • ...then in exe directory
  • ...then platform specific directories
  • fixes ticket 592

9. Comment by mattlewis Feb 22, 2011

See: hg:euphoria/rev/b9d08630810a

changeset: 4664:b9d08630810a branch: 4.0 user: Matt Lewis date: Tue Feb 22 10:15:14 2011 -0500 files: docs/release/4.0.1.txt description:

  • release notes for ticket 592


Quick Links

User menu

Not signed in.

Misc Menu