I have this strange thing when trying to get Gorilla REPL to work for a project I’m involved in. It’s a leiningen project and I have added lein-gorilla “0.3.4”
as a plugin. Starting the REPL I get the expected messages, including the URL at which to access the REPL. But when I do the page renders blank except the “hamburger” menu (which seems to work). And I get two JS errors in tne console:
ReferenceError: Can't find variable: exports: utils.js:13
ReferenceError: Can't find variable: makeHipNSName: main.js:78
If I create a new project then Gorilla works wonderfully.
Anyone have a clue?
@pez Sounds like Gorilla isn't serving up the files ... I wonder whether you're seeing the menu because of browser caching. Is there anything in the project which might interfere with Gorilla's server?
@jonyepsilon: I don’t know what in the project that could interfere… Or even how it could interfere. But yes, since it works in a fresh project I am leaning towards that as well.
As for caching, clearing the cache doesn’t make a difference. Running fresh in another browser gives the same errors and the same behaviour.
Huh. Would be interesting to look at http://127.0.0.1:8990/js/utils.js and see what returns (adjusting the port number to suit).
'use strict';
/**
* Get a deep value from an object by a string path
* For example:
* var foo = {'bar': {'lurker': 'someValue'}}
* getValByPath(foo, 'bar.lurker') returns 'someValue'
*
* @param obj obj
* @param str path
* @return mixed
*/
exports.getValByPath = function(obj, path) {
var p;
if (typeof path === 'string') {
path = path.split('.');
}
if (path.length > 1) {
p = path.shift();
if (typeof obj[p] === 'object') {
return exports.getValByPath(obj[p], path);
} else {
return undefined;
}
} else {
return obj[path[0]];
}
};
That's very odd ... that's not Gorilla REPL code! Should be:
/*
* This file is part of gorilla-repl. Copyright (C) 2014-, Jony Hudson.
*
* gorilla-repl is licenced to you under the MIT licence. See the file LICENCE.txt for full details.
*/
// takes a string and prefixes every line with ';; '
var makeClojureComment = function (code) {
return code.split('\n').map(function (x) {
return ";;; " + x;
}).join("\n")
};
// the funny name indicates that it undoes what the above function does. It doesn't check whether the line is actually
// commented, so will break text that isn't in the format it expects.
var unmakeClojureComment = function (code) {
if (code) {
return code.split('\n').map(function (x) {
return x.slice(4);
}).join("\n");
}
else return null;
};
var makeHipNSName = function () {
// The word lists are taken from Raymond Chan's MIT-licensed <https://github.com/raycchan/bazaar>
var adj = ["affectionate", "amiable", "arrogant", "balmy", "barren", "benevolent", "billowing", "blessed", "breezy", "calm", "celestial", "charming", "combative", "composed", "condemned", "divine", "dry", "energized", "enigmatic", "exuberant", "flowing", "fluffy", "fluttering", "frightened", "fuscia", "gentle", "greasy", "grieving", "harmonious", "hollow", "homeless", "icy", "indigo", "inquisitive", "itchy", "joyful", "jubilant", "juicy", "khaki", "limitless", "lush", "mellow", "merciful", "merry", "mirthful", "moonlit", "mysterious", "natural", "outrageous", "pacific", "parched", "placid", "pleasant", "poised", "purring", "radioactive", "resilient", "scenic", "screeching", "sensitive", "serene", "snowy", "solitary", "spacial", "squealing", "stark", "stunning", "sunset", "talented", "tasteless", "teal", "thoughtless", "thriving", "tranquil", "tropical", "undisturbed", "unsightly", "unwavering", "uplifting", "voiceless", "wandering", "warm", "wealthy", "whispering", "withered", "wooden", "zealous"];
var things = ["abyss", "atoll", "aurora", "autumn", "badlands", "beach", "briars", "brook", "canopy", "canyon", "cavern", "chasm", "cliff", "cove", "crater", "creek", "darkness", "dawn", "desert", "dew", "dove", "drylands", "dusk", "farm", "fern", "firefly", "flowers", "fog", "foliage", "forest", "galaxy", "garden", "geyser", "grove", "hurricane", "iceberg", "lagoon", "lake", "leaves", "marsh", "meadow", "mist", "moss", "mountain", "oasis", "ocean", "peak", "pebble", "pine", "plateau", "pond", "reef", "reserve", "resonance", "sanctuary", "sands", "shelter", "silence", "smokescreen", "snowflake", "spring", "storm", "stream", "summer", "summit", "sunrise", "sunset", "sunshine", "surf", "swamp", "temple", "thorns", "tsunami", "tundra", "valley", "volcano", "waterfall", "willow", "winds", "winter"];
var adjI = Math.floor(Math.random() * adj.length);
var thingsI = Math.floor(Math.random() * things.length);
return adj[adjI] + "-" + things[thingsI];
};
Looks very different from the same in the working project.
Yes, that is what it looks like.
Wonder where that code is coming from ... don't find getValByPath(foo, 'bar.lurker') returns 'someValue'
on Google anywhere.
Key will be figuring out where that comes from, I guess. Any plugins in your profiles.clj that could be messing with ring routes etc?
I find it in my project actually.
(lurker, that is)
Oh, I wonder ... Gorilla serves its files out of the jar's resources. If you're project has resources with the same path (that is resources\public\js\utils.js
then this could happen. Never thought of that!
resources/public/js … i guess that somehow overshadows whatever js/ path gorilla uses
Probably Gorilla should put it's resources somewhere with an unlikely name to avoid this sort of clash.
ha, you figured it out even without looking in my project!
Maybe Gorilla can just load from gorilla-repl/js/...
Yeah, that would work. Should be an easy fix. Was hoping to get a new version out soonish and will put it in that.
Anyway, I can move stuff around and make this work. Many thanks!
Glad we got to the bottom of it :simple_smile:
And we have an issue to track. 😃
Your videos on how to get started are awesome by the way. Not to mention Gorilla itself.
Thanks :simple_smile: Glad you find them useful!