[Command bar] require does not update stored module when changes are made

When using require in the command bar to use modules, changes within modules are not reflected when calling require, despite changes occurring between two distinct require calls.

For example, let’s consider that I create a very simple module which has a single field value and has the value 0. In the command bar, I require this module, and print the value:

local module = {}

module.value = 0

return module

local m = require(workspace.ModuleScript) print(m.value)

I then change the value in the module to 1, and re-run the same above code in the command bar. However, despite changing the value, 0 is still being output in the log.

Obviously, in realistic scenarios these modules contain complex functions that I edit, and then want to re-call, however changes to functions are also not reflected.

I believe this is because once you require a module just one time, it stores it somewhere and just re-calls from that cache of the module, and never invalidates that stored cache of the module even after changes are made. Obviously, I don’t know the inner workings of studio, but that is my guess.

Expected behavior

It should always pull the latest version of the module code whenever you call require from the command bar. If changes are made, then cached requires should be invalidated, and dependency chains should also be re-evaluated if a dependency changes.

If I change value from 0 to 1 in my module, that should be reflected in all new requires.

A workaround does exist, but in involves using cut on all impacted modules, and re-pasting them in, to force a refresh of those modules, which is just really inconvenient to do.

1 Like

AFAIK this isnt really a problem, but instead of re pasting them you can click ‘Reload Script’ on the Script tab
image

2 Likes

Hi,

I changed this to be a Feature Request, because this is currently working as designed.

For now, the workaround is using this in the Command Line:
require(path.to.module:Clone()):runMyFunction()

Btw, feature requests can be shared by creating a thread in this category.

1 Like