You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Emit warning if library is re-imported with different arguments #5492
At the moment if you import a library multiple times like
*** Settings ***Library Example
Library Example
the library is imported every time, but latter imports are silently ignored because there's already a library imported with the same name. This is typically not a problem when a library accepts no arguments or if the library is used with same parameters, but in cases like
*** Settings ***Library Example timeout=1
Library Example timeout=60
the latter import being silently ignored can cause a lot of confusion. In the above case it's easy to see there's something strange when both imports are in the same file, but the same problem occurs also if imports are, for example, in two different resource files that are both imported by a suite file.
As issue #5122 demonstrates, the problem with silently ignored imports occurs also when using import aliases if the same alias is reused.
To avoid these problems, I propose we start emitting a warning if a library is re-imported with the same name and the latter import is ignored. That way users immediately learn about ignored imports and can fix the situation.
UPDATE: The original design was changes so that now there's a warning only if a library is re-imported with different arguments.
Although this change doesn't break any tests, I decided to label this issue as backwards incompatible. The reason is that there can be a lot of warnings and they can be somewhat distracting. For example, when I run Robot's own acceptance tests with a prototype implementation of this feature, there were ~50 warnings. Most of them were caused by two widely used resource files both importing the OperatingSystem library and fixing that simply required removing one of the imports. All these imports also used libraries without arguments and thus were harmless. If there turn out to be a huge number of such warnings during the preview release time, we can still consider changing the behavior so that we emit a warning only if a library is re-imported with arguments.
changed the title [-]Emit warning if same library is imported multiple times[/-][+]Emit warning if library is re-imported with different arguments[/+]on Sep 2, 2025
Based on the discussion on Slack, I decided to change the design so that there's a warning only if a library is re-imported with different arguments. This avoids warnings in cases where a library like OperatingSystem is imported in different resource files used by one suite. Users are anyway informed about cases where library configuration is ignored because the library has already been imported using different config.
I also decided to warn about cases where a library is imported using an alias that is used already by another library. Also in this case the latter import is ignored and it makes sense to inform users about that.
After the aforementioned design change, I don't consider this at all backwards incompatible.
Activity
pekkaklarck commentedon Aug 29, 2025
Although this change doesn't break any tests, I decided to label this issue as backwards incompatible. The reason is that there can be a lot of warnings and they can be somewhat distracting. For example, when I run Robot's own acceptance tests with a prototype implementation of this feature, there were ~50 warnings. Most of them were caused by two widely used resource files both importing the OperatingSystem library and fixing that simply required removing one of the imports. All these imports also used libraries without arguments and thus were harmless. If there turn out to be a huge number of such warnings during the preview release time, we can still consider changing the behavior so that we emit a warning only if a library is re-imported with arguments.
Remove duplicate imports
Add owner info to dynamic imports
[-]Emit warning if same library is imported multiple times[/-][+]Emit warning if library is re-imported with different arguments[/+]pekkaklarck commentedon Sep 2, 2025
Based on the discussion on Slack, I decided to change the design so that there's a warning only if a library is re-imported with different arguments. This avoids warnings in cases where a library like
OperatingSystemis imported in different resource files used by one suite. Users are anyway informed about cases where library configuration is ignored because the library has already been imported using different config.I also decided to warn about cases where a library is imported using an alias that is used already by another library. Also in this case the latter import is ignored and it makes sense to inform users about that.
After the aforementioned design change, I don't consider this at all backwards incompatible.
Emit warning if library is reimported with different args