"Loading failed for script" js errors during moodle 3.5.6 install (and after on cli installed site)

"Loading failed for script" js errors during moodle 3.5.6 install (and after on cli installed site)

by Abraham Ott -
Number of replies: 2

I'm at my wit's end here.  I'm trying to install moodle 3.5, and it's failing to load some js scripts, which means I can't add the admin pwd.  Installing from cli works, but when I go to the page it's missing css and js. 

History and setup: 
Windows 2012 R2, IIS, MySql, PHP 7.1
Many moodle sites of various versions already running on the server for a long time, including some 3.5. They run fine.

I installed a moodle 3.5.6 last year with no problems that I can recall. Then last month I tried to install the latest 3.5 and it failed, not loading some css and js, and thus the admin pwd link not working.  Thought it might be the version, so tried the 3.5.6 I still had from last year's download. Same problem. 

Why on earth is this suddenly a problem?!?!?

After much research, tried these fixes:

  • verified php.ini has cgi.fix_pathinfo = 1
  • set $CFG->yuislasharguments = 1; in config.php
  • set yui rewrite rule in IIS
  • changed config.php encoding from ansi to UTF-8

  • set zlib compression -- this helped; I got formatting on the first page, but admin link still broken

  • regedit created FastCGIUtf8ServerVariables entry

  • Switched to firefox (had been using chrome)

And then finally it worked!! Console wasn't perfect, but I got formatting and the admin pwd link worked.  Once it was installed, everything worked perfectly. 

That was last month. Now I try to create another moodle 3.5.6 site, and I get the same problem!!! JS and css fail, and I can't click the admin pwd link during installation. I have everything in place that made it work last month. Tried it without yuislasharguments in config.php. Still fail. Tried IE. Still fail. 

Then I tried installing it via cli (my first time with that).  It installed fine. But when I go the to new site, css and js are broken. 

This is what I get in firefox console (from the cli installed but still broken site; was same during installation at the admin config page): 


TypeError: require is not a function
ReferenceError: Y is not defined
The Components object is deprecated. It will soon be removed. develop35_2
undefined

And this is what I get in chrome (after login): 

index.php?returnurl=%2Findex.php:11 GET https://temp.XXXXXXXX.com/develop35_2/theme/yui_combo.php?rollup/3.17.2/yui-moodlesimple-min.css net::ERR_CONTENT_DECODING_FAILED 200 (OK)

index.php?returnurl=%2Findex.php:11 GET https://temp.XXXXXXXX.com/develop35_2/theme/yui_combo.php?rollup/3.17.2/yui-moodlesimple-min.css net::ERR_CONTENT_DECODING_FAILED 200 (OK)

index.php?returnurl=%2Findex.php:33 GET https://temp.XXXXXXXX.com/develop35_2/theme/yui_combo.php?rollup/3.17.2/yui-moodlesimple-min.js net::ERR_CONTENT_DECODING_FAILED 200 (OK)

index.php?returnurl=%2Findex.php:33 GET https://temp.XXXXXXXX.com/develop35_2/theme/yui_combo.php?rollup/3.17.2/yui-moodlesimple-min.js net::ERR_CONTENT_DECODING_FAILED 200 (OK)

index.php?returnurl=%2Findex.php:1823 GET https://temp.XXXXXXXX.com/develop35_2/lib/javascript.php/1588223788/lib/requirejs/require.min.js net::ERR_CONTENT_DECODING_FAILED 200 (OK)

index.php?returnurl=%2Findex.php:1826 Uncaught TypeError: require is not a function

at index.php?returnurl=%2Findex.php:1826

(anonymous) @ 

index.php?returnurl=%2Findex.php:1826

index.php?returnurl=%2Findex.php:2272 Uncaught TypeError: M.yui.add_module is not a function

at index.php?returnurl=%2Findex.php:2272

(anonymous) @ 

index.php?returnurl=%2Findex.php:2272

index.php?returnurl=%2Findex.php:2283 Uncaught ReferenceError: Y is not defined

at index.php?returnurl=%2Findex.php:2283

at index.php?returnurl=%2Findex.php:2292

(anonymous) @ 

index.php?returnurl=%2Findex.php:2283

(anonymous) @ 

index.php?returnurl=%2Findex.php:2292

DevTools failed to load SourceMap: Could not load content for chrome-extension://abnnemjpaacaimkkepphpkaiomnafldi/common/browser-polyfill.js.map: HTTP error: status code 404, net::ERR_UNKNOWN_URL_SCHEME


What in heaven's name is going on here? And what can I still do to fix it? 

Average of ratings: -
In reply to Abraham Ott

Re: "Loading failed for script" js errors during moodle 3.5.6 install (and after on cli installed site)

by Leon Stringer -
Picture of Core developers Picture of Particularly helpful Moodlers

You've redacted the site domain name in the output but the links still contain this. Hopefully this doesn't mean you've leaked any sensitive information. It has the advantage that we can see the problem directly.

It looks like 1) debugging is enabled for the site and 2) config.php contains a deprecated implicit object creation, presumably for $CFG.

This is causing JavaScript content to be served with an HTML fragment containing a PHP warning inserted at the start which the browser isn't expecting.

The sample config-dist.php shows how $CFG should be created (from Moodle 1.9 onwards):

unset($CFG);  // Ignore this line
global $CFG;  // This is necessary here for PHPUnit execution
$CFG = new stdClass();

ensure the top of config.php matches, these lines should appear before any $CFG->property = … lines.


Average of ratings: Useful (1)
In reply to Leon Stringer

Re: "Loading failed for script" js errors during moodle 3.5.6 install (and after on cli installed site)

by Abraham Ott -
THANK YOU! That was exactly it.

Wasn't too terribly important about the links; I'm glad it happened and this is resolved.