question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

build error: variables undeclared

See original GitHub issue

Hi, I’m trying to compile blockly-games on Mac OSx Sierra 10.12.2

I was able to git clone and make deps, but when I run make maze-en (as an example) I get the following errors and warnings

any suggestion? thank you in advance Elena

=========================

third-party/build/closurebuilder.py: Compiling with the following command: java -client -jar third-party/closure-compiler.jar --flagfile /var/folders/86/1ltscfs5125g7q30mv875t_40000gn/T/tmpFRkQ9j
appengine/maze/js/maze.js:409: WARNING - Redeclared variable: tile
      var tile = document.createElementNS(Blockly.SVG_NS, 'image');
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

appengine/maze/js/maze.js:1389: WARNING - Redeclared variable: x
  for (var x = 0, path; path = paths[x]; x++) {
           ^^^^^

appengine/third-party/blockly/core/block.js:1017: WARNING - Redeclared variable: i
    for (var i = 0; i < extensionNames.length; ++i) {
             ^^^^^

appengine/third-party/blockly/core/extensions.js:58: WARNING - Bad type annotation. missing opening ( See https://github.com/google/closure-compiler/wiki/Bad-Type-Annotation for more information.
 * @param {function} initFn The function to initialize an extended block.
                   ^

appengine/third-party/blockly/core/trashcan.js:185: WARNING - Redeclared variable: clip
  var clip = Blockly.utils.createSvgElement('clipPath',
      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

appengine/third-party/blockly/core/utils.js:200: WARNING - Redeclared variable: scale
    var scale = Blockly.utils.getScale_(element);
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

appengine/third-party/blockly/core/xml.js:357: WARNING - Redeclared variable: bbox
      var bbox = workspace.getBlocksBoundingBox();
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

appengine/third-party/blockly/core/zoom_controls.js:135: WARNING - Redeclared variable: clip
  var clip = Blockly.utils.createSvgElement('clipPath',
      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

appengine/third-party/blockly/core/zoom_controls.js:151: WARNING - Redeclared variable: clip
  var clip = Blockly.utils.createSvgElement('clipPath',
      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

appengine/third-party/blockly/generators/javascript.js:243: WARNING - Redeclared variable: comment
          var comment = Blockly.JavaScript.allNestedComments(childBlock);
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

appengine/js/lib-dialogs.js:374: ERROR - variable prettyPrintOne is undeclared
    if (typeof prettyPrintOne == 'function') {
               ^^^^^^^^^^^^^^

appengine/js/lib-interface.js:50: ERROR - variable BlocklyStorage is undeclared
    BlocklyStorage['HTTPREQUEST_ERROR'] =
    ^^^^^^^^^^^^^^

2 error(s), 10 warning(s)
Traceback (most recent call last):
  File "third-party/build/closurebuilder.py", line 293, in <module>
    main()
  File "third-party/build/closurebuilder.py", line 282, in main
    compiler_flags=options.compiler_flags)
  File "/Users/elena/blockly-games/third-party/build/jscompiler.py", line 159, in Compile
    raise JsCompilerError('JavaScript compilation failed.')
jscompiler.JsCompilerError: JavaScript compilation failed.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:7 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
NeilFrasercommented, May 1, 2017

Both are defined in files that Closure Compiler can’t see. The proper way to fix this would be to create externs for them. Try editing this file: https://github.com/google/blockly-games/blob/master/externs/interpreter-externs.js And add the following at the end:

var BlocklyStorage = {};
BlocklyStorage.backupOnUnload = function() {};
BlocklyStorage.restoreBlocks = function() {};
BlocklyStorage.link = function() {};
BlocklyStorage.retrieveXml = function(key) {};
BlocklyStorage.alert = function(message) {};
var prettyPrintOne = function(code, lang) {};
0reactions
NeilFrasercommented, Nov 6, 2017

Several dependencies (including Blockly) changed over time, breaking the build. Blockly Games has been updated so that everything builds properly now.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to avoid Compile Error while defining Variables
The identifier is undeclared: In any programming language, all variables have to be declared before they are used. · No initial value is...
Read more >
ReferenceError: assignment to undeclared variable "x"
A value has been assigned to an undeclared variable. In other words, there was an assignment without the var keyword. There are some...
Read more >
ERROR - variable console is undeclared - Google Groups
I am using simple compilation level and the compiler is complaining about the variable console is not defined. console.log("Hello World");
Read more >
Compiler says variable is undeclared even though it is declared
c - Compiler says variable is undeclared even though it is declared - Stack Overflow. Stack Overflow for Teams – Start collaborating and ......
Read more >
Undeclared variable error for a declared variable - Reddit
Undeclared variable error for a declared variable. so I've been struggling with compiling my program that I am developing for an LPC2478-STK ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found